Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,36 @@ new glue.RayJob(stack, 'ImportedJob', {
});
```

### Metrics Control

By default, Glue jobs enable CloudWatch metrics (`--enable-metrics`) and observability metrics (`--enable-observability-metrics`) for monitoring and debugging. You can disable these metrics to reduce CloudWatch costs:

```ts
import * as cdk from 'aws-cdk-lib';
import * as iam from 'aws-cdk-lib/aws-iam';
declare const stack: cdk.Stack;
declare const role: iam.IRole;
declare const script: glue.Code;

// Disable both metrics for cost optimization
new glue.PySparkEtlJob(stack, 'CostOptimizedJob', {
role,
script,
enableMetrics: false,
enableObservabilityMetrics: false,
});

// Selective control - keep observability, disable profiling
new glue.PySparkEtlJob(stack, 'SelectiveJob', {
role,
script,
enableMetrics: false,
// enableObservabilityMetrics defaults to true
});
```

This feature is available for all Spark job types (ETL, Streaming, Flex) and Ray jobs.

### Enable Job Run Queuing

AWS Glue job queuing monitors your account level quotas and limits. If quotas or limits are insufficient to start a Glue job run, AWS Glue will automatically queue the job and wait for limits to free up. Once limits become available, AWS Glue will retry the job run. Glue jobs will queue for limits like max concurrent job runs per account, max concurrent Data Processing Units (DPU), and resource unavailable due to IP address exhaustion in Amazon Virtual Private Cloud (Amazon VPC).
Expand Down
24 changes: 22 additions & 2 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/ray-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ export interface RayJobProps extends JobProps {
* @default - no job run queuing
*/
readonly jobRunQueuingEnabled?: boolean;

/**
* Enable profiling metrics for the Glue job.
*
* When enabled, adds '--enable-metrics' to job arguments.
*
* @default true
*/
readonly enableMetrics?: boolean;

/**
* Enable observability metrics for the Glue job.
*
* When enabled, adds '--enable-observability-metrics': 'true' to job arguments.
*
* @default true
*/
readonly enableObservabilityMetrics?: boolean;
}

/**
Expand Down Expand Up @@ -66,8 +84,10 @@ export class RayJob extends Job {

// Enable CloudWatch metrics and continuous logging by default as a best practice
const continuousLoggingArgs = this.setupContinuousLogging(this.role, props.continuousLogging);
const profilingMetricsArgs = { '--enable-metrics': '' };
const observabilityMetricsArgs = { '--enable-observability-metrics': 'true' };

// Conditionally include metrics arguments (default to enabled for backward compatibility)
const profilingMetricsArgs = (props.enableMetrics ?? true) ? { '--enable-metrics': '' } : {};
const observabilityMetricsArgs = (props.enableObservabilityMetrics ?? true) ? { '--enable-observability-metrics': 'true' } : {};

// Combine command line arguments into a single line item
const defaultArguments = {
Expand Down
24 changes: 22 additions & 2 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/spark-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ export interface SparkJobProps extends JobProps {
* @see https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html
*/
readonly sparkUI?: SparkUIProps;

/**
* Enable profiling metrics for the Glue job.
*
* When enabled, adds '--enable-metrics' to job arguments.
*
* @default true
*/
readonly enableMetrics?: boolean;

/**
* Enable observability metrics for the Glue job.
*
* When enabled, adds '--enable-observability-metrics': 'true' to job arguments.
*
* @default true
*/
readonly enableObservabilityMetrics?: boolean;
}

/**
Expand Down Expand Up @@ -134,8 +152,10 @@ export abstract class SparkJob extends Job {
protected nonExecutableCommonArguments(props: SparkJobProps): {[key: string]: string} {
// Enable CloudWatch metrics and continuous logging by default as a best practice
const continuousLoggingArgs = this.setupContinuousLogging(this.role, props.continuousLogging);
const profilingMetricsArgs = { '--enable-metrics': '' };
const observabilityMetricsArgs = { '--enable-observability-metrics': 'true' };

// Conditionally include metrics arguments (default to enabled for backward compatibility)
const profilingMetricsArgs = (props.enableMetrics ?? true) ? { '--enable-metrics': '' } : {};
const observabilityMetricsArgs = (props.enableObservabilityMetrics ?? true) ? { '--enable-observability-metrics': 'true' } : {};

// Set spark ui args, if spark ui logging had been setup
const sparkUIArgs = this.sparkUILoggingLocation ? ({
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading