From 13f3459476dd59dd0558800e3c26b58aaaa7d125 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:52:33 +0900 Subject: [PATCH] modify comments and add sample code --- .../aws-cdk-lib/aws-cloudwatch/lib/metric.ts | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts b/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts index 444d1073220af..1db855c817bc5 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts @@ -226,9 +226,33 @@ 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 + * new 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. */