diff --git a/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts b/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts index 444d1073220af..e0594987cbd42 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts @@ -226,9 +226,34 @@ export interface MathExpressionProps extends MathExpressionOptions { * The key is the identifier that represents the given metric in the * expression, and the value is the actual Metric object. * - * The `period` of each Metric object is ignored and instead overridden by - * the `period` of this math expression object. Even if the `period` of the - * math expression is not specified, it is overridden by its default value. + * The `period` of each metric in `usingMetrics` is ignored and instead overridden + * by the `period` specified for the `MathExpression` construct. Even if no `period` + * is specified for the `MathExpression`, it will be overridden by the default + * value (`Duration.minutes(5)`). + * + * Example: + * + * ```ts + * declare const metrics: elbv2.IApplicationLoadBalancerMetrics; + * new cloudwatch.MathExpression({ + * expression: 'm1+m2', + * label: 'AlbErrors', + * usingMetrics: { + * m1: metrics.custom('HTTPCode_ELB_500_Count', { + * period: Duration.minutes(1), // <- This period will be ignored + * statistic: 'Sum', + * label: 'HTTPCode_ELB_500_Count', + * }), + * m2: metrics.custom('HTTPCode_ELB_502_Count', { + * period: Duration.minutes(1), // <- This period will be ignored + * statistic: 'Sum', + * label: 'HTTPCode_ELB_502_Count', + * }), + * }, + * period: Duration.minutes(3), // <- This overrides the period of each metric in `usingMetrics` + * // (Even if not specified, it is overridden by the default value) + * }); + * ``` * * @default - Empty map. */ diff --git a/packages/aws-cdk-lib/rosetta/aws_cloudwatch/default.ts-fixture b/packages/aws-cdk-lib/rosetta/aws_cloudwatch/default.ts-fixture index 8783a1272fe84..399a0d1eee7c3 100644 --- a/packages/aws-cdk-lib/rosetta/aws_cloudwatch/default.ts-fixture +++ b/packages/aws-cdk-lib/rosetta/aws_cloudwatch/default.ts-fixture @@ -2,6 +2,7 @@ import { Construct } from 'constructs'; import { Stack, Duration } from 'aws-cdk-lib'; import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch'; +import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2'; import * as route53 from 'aws-cdk-lib/aws-route53'; import * as sns from 'aws-cdk-lib/aws-sns'; import * as lambda from 'aws-cdk-lib/aws-lambda';