From 704d864461d488a0adf3b759c2cba61ea779636e Mon Sep 17 00:00:00 2001 From: Eugene Cheung <81188333+echeung-amzn@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:02:01 -0400 Subject: [PATCH] fix: apply account/region to more metrics (#544) Addressing a few misses from #533. Also updates the test in `MonitoringFacade.test.ts` since XAXR alarms aren't possible. Fixes #434, but only in cases where we can infer that the account/region is actually different from the construct scope to prevent unnecessary XAXR alarm errors. Fixes #428, in cases where the account/region is actually different from the construct scope. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_ --- API.md | 9 +- lib/common/metric/MetricFactory.ts | 98 +++++++++++++++++-- lib/facade/MonitoringFacade.ts | 7 +- ...oTableGlobalSecondaryIndexMetricFactory.ts | 4 + .../aws-dynamo/DynamoTableMetricFactory.ts | 20 ++++ .../KinesisFirehoseMetricFactory.ts | 12 +++ .../LambdaFunctionEnhancedMetricFactory.ts | 2 + .../aws-lambda/LambdaFunctionMetricFactory.ts | 2 + .../RedshiftClusterMetricFactory.ts | 20 ++++ .../aws-sqs/SqsQueueMetricFactory.ts | 12 +++ ...FunctionServiceIntegrationMetricFactory.ts | 3 + .../aws-wafv2/WafV2MetricFactory.ts | 4 + test/common/metric/MetricFactory.test.ts | 29 ++++-- .../__snapshots__/MetricFactory.test.ts.snap | 93 +++++++++++------- test/facade/MonitoringFacade.test.ts | 17 +++- .../MonitoringAspect.test.ts.snap | 52 ++-------- .../MonitoringFacade.test.ts.snap | 80 ++++++--------- test/monitoring/TestMonitoringScope.ts | 5 +- .../CloudFrontDistribution.test.ts | 6 +- .../CloudFrontDistribution.test.ts.snap | 64 ++++++------ .../WafV2Monitoring.test.ts.snap | 4 +- .../custom/CustomMonitoring.test.ts | 11 ++- 22 files changed, 367 insertions(+), 187 deletions(-) diff --git a/API.md b/API.md index 1e104104..345b02ad 100644 --- a/API.md +++ b/API.md @@ -65886,12 +65886,13 @@ public readonly title: string; ```typescript import { MetricFactory } from 'cdk-monitoring-constructs' -new MetricFactory(props?: MetricFactoryProps) +new MetricFactory(props?: MetricFactoryProps, scope?: Construct) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | props | MetricFactoryProps | *No description.* | +| scope | constructs.Construct | *No description.* | --- @@ -65901,6 +65902,12 @@ new MetricFactory(props?: MetricFactoryProps) --- +##### `scope`Optional + +- *Type:* constructs.Construct + +--- + #### Methods | **Name** | **Description** | diff --git a/lib/common/metric/MetricFactory.ts b/lib/common/metric/MetricFactory.ts index 2cfebb65..6296bead 100644 --- a/lib/common/metric/MetricFactory.ts +++ b/lib/common/metric/MetricFactory.ts @@ -1,10 +1,11 @@ -import { Duration } from "aws-cdk-lib"; +import { Duration, Stack } from "aws-cdk-lib"; import { DimensionsMap, IMetric, MathExpression, Metric, } from "aws-cdk-lib/aws-cloudwatch"; +import { Construct } from "constructs"; import { AnomalyDetectionMathExpression } from "./AnomalyDetectionMathExpression"; import { BaseMetricFactoryProps } from "./BaseMetricFactory"; @@ -42,9 +43,12 @@ export interface MetricFactoryProps { export class MetricFactory { protected readonly globalDefaults: MetricFactoryDefaults; + protected readonly scope: Construct | undefined; - constructor(props?: MetricFactoryProps) { + // TODO: make scope required and first. This is for backwards compatability for now. + constructor(props?: MetricFactoryProps, scope?: Construct) { this.globalDefaults = props?.globalDefaults ?? {}; + this.scope = scope; } /** @@ -81,8 +85,8 @@ export class MetricFactory { : undefined, namespace: this.getNamespaceWithFallback(namespace), period: period ?? this.globalDefaults.period ?? DefaultMetricPeriod, - region: region ?? this.globalDefaults.region, - account: account ?? this.globalDefaults.account, + region: this.resolveRegion(region ?? this.globalDefaults.region), + account: this.resolveAccount(account ?? this.globalDefaults.account), }); } @@ -112,8 +116,10 @@ export class MetricFactory { expression, usingMetrics, period: period ?? this.globalDefaults.period ?? DefaultMetricPeriod, - searchRegion: region ?? this.globalDefaults.region, - searchAccount: account ?? this.globalDefaults.account, + searchRegion: this.resolveRegion(region ?? this.globalDefaults.region), + searchAccount: this.resolveAccount( + account ?? this.globalDefaults.account, + ), }); } @@ -165,8 +171,10 @@ export class MetricFactory { // cannot be an empty string and undefined is no good either label: label ?? " ", period: finalPeriod, - searchRegion: region ?? this.globalDefaults.region, - searchAccount: account ?? this.globalDefaults.account, + searchRegion: this.resolveRegion(region ?? this.globalDefaults.region), + searchAccount: this.resolveAccount( + account ?? this.globalDefaults.account, + ), }); } @@ -205,8 +213,10 @@ export class MetricFactory { usingMetrics, expression: `ANOMALY_DETECTION_BAND(${finalExpressionId},${stdev})`, period: period ?? this.globalDefaults.period ?? DefaultMetricPeriod, - searchRegion: region ?? this.globalDefaults.region, - searchAccount: account ?? this.globalDefaults.account, + searchRegion: this.resolveRegion(region ?? this.globalDefaults.region), + searchAccount: this.resolveAccount( + account ?? this.globalDefaults.account, + ), }); } @@ -263,6 +273,8 @@ export class MetricFactory { label, metric.color, metric.period, + this.getRegion(metric), + this.getAccount(metric), ); } } @@ -296,6 +308,8 @@ export class MetricFactory { label, metric.color, metric.period, + this.getRegion(metric), + this.getAccount(metric), ); } } @@ -351,6 +365,8 @@ export class MetricFactory { avgLabel, avgMetric.color, avgMetric.period, + this.getRegion(avgMetric), + this.getAccount(avgMetric), ); } return avgMetric; @@ -370,6 +386,8 @@ export class MetricFactory { perSecondLabel, metric.color, metric.period, + this.getRegion(metric), + this.getAccount(metric), ); case RateComputationMethod.PER_MINUTE: return this.createMetricMath( @@ -378,6 +396,8 @@ export class MetricFactory { `${labelPrefix}/m${labelAppendix}`, metric.color, metric.period, + this.getRegion(metric), + this.getAccount(metric), ); case RateComputationMethod.PER_HOUR: return this.createMetricMath( @@ -386,6 +406,8 @@ export class MetricFactory { `${labelPrefix}/h${labelAppendix}`, metric.color, metric.period, + this.getRegion(metric), + this.getAccount(metric), ); case RateComputationMethod.PER_DAY: return this.createMetricMath( @@ -394,6 +416,8 @@ export class MetricFactory { `${labelPrefix}/d${labelAppendix}`, metric.color, metric.period, + this.getRegion(metric), + this.getAccount(metric), ); } } @@ -452,4 +476,58 @@ export class MetricFactory { return copy; } + + /** + * Attempts to get the account from the metric if it differs from the scope. + */ + private resolveAccount( + metricAccount: string | undefined, + ): string | undefined { + if (!this.scope) { + return metricAccount; + } + + const { account } = Stack.of(this.scope); + if (metricAccount !== account) { + return metricAccount; + } + + return; + } + private getAccount(metric: MetricWithAlarmSupport): string | undefined { + let metricAccount: string | undefined; + if (metric instanceof MathExpression) { + metricAccount = metric.searchAccount; + } else { + metricAccount = metric.account; + } + + return this.resolveAccount(metricAccount); + } + + /** + * Attempts to get the region from the metric if it differs from the scope. + */ + private resolveRegion(metricRegion: string | undefined): string | undefined { + if (!this.scope) { + return metricRegion; + } + + const { region } = Stack.of(this.scope); + if (metricRegion !== region) { + return metricRegion; + } + + return; + } + private getRegion(metric: MetricWithAlarmSupport): string | undefined { + let metricRegion: string | undefined; + if (metric instanceof MathExpression) { + metricRegion = metric.searchRegion; + } else { + metricRegion = metric.region; + } + + return this.resolveRegion(metricRegion); + } } diff --git a/lib/facade/MonitoringFacade.ts b/lib/facade/MonitoringFacade.ts index a52a7c4e..e3620795 100644 --- a/lib/facade/MonitoringFacade.ts +++ b/lib/facade/MonitoringFacade.ts @@ -202,7 +202,12 @@ export class MonitoringFacade extends MonitoringScope { } createMetricFactory(): MetricFactory { - return new MetricFactory({ globalDefaults: this.metricFactoryDefaults }); + return new MetricFactory( + { + globalDefaults: this.metricFactoryDefaults, + }, + this, + ); } createWidgetFactory(): IWidgetFactory { diff --git a/lib/monitoring/aws-dynamo/DynamoTableGlobalSecondaryIndexMetricFactory.ts b/lib/monitoring/aws-dynamo/DynamoTableGlobalSecondaryIndexMetricFactory.ts index 710cb257..05269deb 100644 --- a/lib/monitoring/aws-dynamo/DynamoTableGlobalSecondaryIndexMetricFactory.ts +++ b/lib/monitoring/aws-dynamo/DynamoTableGlobalSecondaryIndexMetricFactory.ts @@ -68,6 +68,8 @@ export class DynamoTableGlobalSecondaryIndexMetricFactory extends BaseMetricFact consumed_rcu_sum: this.table.metricConsumedReadCapacityUnits({ statistic: MetricStatistic.SUM, dimensionsMap: this.dimensionsMap, + region: this.region, + account: this.account, }), }, "Consumed", @@ -81,6 +83,8 @@ export class DynamoTableGlobalSecondaryIndexMetricFactory extends BaseMetricFact consumed_wcu_sum: this.table.metricConsumedWriteCapacityUnits({ statistic: MetricStatistic.SUM, dimensionsMap: this.dimensionsMap, + region: this.region, + account: this.account, }), }, "Consumed", diff --git a/lib/monitoring/aws-dynamo/DynamoTableMetricFactory.ts b/lib/monitoring/aws-dynamo/DynamoTableMetricFactory.ts index f7a4e7a7..246e1ab7 100644 --- a/lib/monitoring/aws-dynamo/DynamoTableMetricFactory.ts +++ b/lib/monitoring/aws-dynamo/DynamoTableMetricFactory.ts @@ -72,6 +72,10 @@ export class DynamoTableMetricFactory extends BaseMetricFactory { }); test("snapshot test: toRate with detail", () => { - const metricFactory = new MetricFactory({ - globalDefaults: { - namespace: "DummyNamespace", + const stack = new Stack(); + const metricFactory = new MetricFactory( + { + globalDefaults: { + namespace: "DummyNamespace", + }, }, - }); + stack, + ); const metric = metricFactory.createMetric( "Metric", MetricStatistic.SUM, "Label", + undefined, + Color.ORANGE, + "Namespace", + undefined, + "eu-west-1", + "01234567890", ); const metricAverage = metricFactory.toRate( @@ -186,6 +196,13 @@ test("snapshot test: toRate with detail", () => { ); expect(metricAverage).toMatchSnapshot(); + const metricAverageWithAccount = metricFactory.toRate( + metric.with({ account: "1111111111" }), + RateComputationMethod.AVERAGE, + true, + ); + expect(metricAverageWithAccount).toMatchSnapshot(); + const metricPerSecond = metricFactory.toRate( metric, RateComputationMethod.PER_SECOND, diff --git a/test/common/metric/__snapshots__/MetricFactory.test.ts.snap b/test/common/metric/__snapshots__/MetricFactory.test.ts.snap index 32f8e0fc..ca773302 100644 --- a/test/common/metric/__snapshots__/MetricFactory.test.ts.snap +++ b/test/common/metric/__snapshots__/MetricFactory.test.ts.snap @@ -889,12 +889,12 @@ Object { exports[`snapshot test: toRate with detail 1`] = ` Metric { - "account": undefined, - "color": undefined, + "account": "01234567890", + "color": "#ff7f0e", "dimensions": undefined, "label": "Label (avg) (min: \${MIN}, max: \${MAX})", "metricName": "Metric", - "namespace": "DummyNamespace", + "namespace": "Namespace", "period": Duration { "amount": 5, "unit": TimeUnit { @@ -903,7 +903,7 @@ Metric { "label": "minutes", }, }, - "region": undefined, + "region": "eu-west-1", "statistic": "Average", "unit": undefined, "warnings": undefined, @@ -911,8 +911,31 @@ Metric { `; exports[`snapshot test: toRate with detail 2`] = ` +Metric { + "account": "1111111111", + "color": "#ff7f0e", + "dimensions": undefined, + "label": "Label (avg) (min: \${MIN}, max: \${MAX})", + "metricName": "Metric", + "namespace": "Namespace", + "period": Duration { + "amount": 5, + "unit": TimeUnit { + "inMillis": 60000, + "isoLabel": "M", + "label": "minutes", + }, + }, + "region": "eu-west-1", + "statistic": "Average", + "unit": undefined, + "warnings": undefined, +} +`; + +exports[`snapshot test: toRate with detail 3`] = ` MathExpression { - "color": undefined, + "color": "#ff7f0e", "expression": "m1 / PERIOD(m1)", "label": "Label/s (min: \${MIN}, max: \${MAX}, avg: \${AVG})", "period": Duration { @@ -923,16 +946,16 @@ MathExpression { "label": "minutes", }, }, - "searchAccount": undefined, - "searchRegion": undefined, + "searchAccount": "01234567890", + "searchRegion": "eu-west-1", "usingMetrics": Object { "m1": Metric { - "account": undefined, - "color": undefined, + "account": "01234567890", + "color": "#ff7f0e", "dimensions": undefined, "label": "Label", "metricName": "Metric", - "namespace": "DummyNamespace", + "namespace": "Namespace", "period": Duration { "amount": 5, "unit": TimeUnit { @@ -941,7 +964,7 @@ MathExpression { "label": "minutes", }, }, - "region": undefined, + "region": "eu-west-1", "statistic": "Sum", "unit": undefined, "warnings": undefined, @@ -950,9 +973,9 @@ MathExpression { } `; -exports[`snapshot test: toRate with detail 3`] = ` +exports[`snapshot test: toRate with detail 4`] = ` MathExpression { - "color": undefined, + "color": "#ff7f0e", "expression": "(60 * m1) / PERIOD(m1)", "label": "Label/m (min: \${MIN}, max: \${MAX}, avg: \${AVG})", "period": Duration { @@ -963,16 +986,16 @@ MathExpression { "label": "minutes", }, }, - "searchAccount": undefined, - "searchRegion": undefined, + "searchAccount": "01234567890", + "searchRegion": "eu-west-1", "usingMetrics": Object { "m1": Metric { - "account": undefined, - "color": undefined, + "account": "01234567890", + "color": "#ff7f0e", "dimensions": undefined, "label": "Label", "metricName": "Metric", - "namespace": "DummyNamespace", + "namespace": "Namespace", "period": Duration { "amount": 5, "unit": TimeUnit { @@ -981,7 +1004,7 @@ MathExpression { "label": "minutes", }, }, - "region": undefined, + "region": "eu-west-1", "statistic": "Sum", "unit": undefined, "warnings": undefined, @@ -990,9 +1013,9 @@ MathExpression { } `; -exports[`snapshot test: toRate with detail 4`] = ` +exports[`snapshot test: toRate with detail 5`] = ` MathExpression { - "color": undefined, + "color": "#ff7f0e", "expression": "(3600 * m1) / PERIOD(m1)", "label": "Label/h (min: \${MIN}, max: \${MAX}, avg: \${AVG})", "period": Duration { @@ -1003,16 +1026,16 @@ MathExpression { "label": "minutes", }, }, - "searchAccount": undefined, - "searchRegion": undefined, + "searchAccount": "01234567890", + "searchRegion": "eu-west-1", "usingMetrics": Object { "m1": Metric { - "account": undefined, - "color": undefined, + "account": "01234567890", + "color": "#ff7f0e", "dimensions": undefined, "label": "Label", "metricName": "Metric", - "namespace": "DummyNamespace", + "namespace": "Namespace", "period": Duration { "amount": 5, "unit": TimeUnit { @@ -1021,7 +1044,7 @@ MathExpression { "label": "minutes", }, }, - "region": undefined, + "region": "eu-west-1", "statistic": "Sum", "unit": undefined, "warnings": undefined, @@ -1030,9 +1053,9 @@ MathExpression { } `; -exports[`snapshot test: toRate with detail 5`] = ` +exports[`snapshot test: toRate with detail 6`] = ` MathExpression { - "color": undefined, + "color": "#ff7f0e", "expression": "(86400 * m1) / PERIOD(m1)", "label": "Label/d (min: \${MIN}, max: \${MAX}, avg: \${AVG})", "period": Duration { @@ -1043,16 +1066,16 @@ MathExpression { "label": "minutes", }, }, - "searchAccount": undefined, - "searchRegion": undefined, + "searchAccount": "01234567890", + "searchRegion": "eu-west-1", "usingMetrics": Object { "m1": Metric { - "account": undefined, - "color": undefined, + "account": "01234567890", + "color": "#ff7f0e", "dimensions": undefined, "label": "Label", "metricName": "Metric", - "namespace": "DummyNamespace", + "namespace": "Namespace", "period": Duration { "amount": 5, "unit": TimeUnit { @@ -1061,7 +1084,7 @@ MathExpression { "label": "minutes", }, }, - "region": undefined, + "region": "eu-west-1", "statistic": "Sum", "unit": undefined, "warnings": undefined, diff --git a/test/facade/MonitoringFacade.test.ts b/test/facade/MonitoringFacade.test.ts index 579a9aaf..b79142fb 100644 --- a/test/facade/MonitoringFacade.test.ts +++ b/test/facade/MonitoringFacade.test.ts @@ -2,6 +2,7 @@ import { Duration, Stack } from "aws-cdk-lib"; import { Capture, Template } from "aws-cdk-lib/assertions"; import { TextWidget } from "aws-cdk-lib/aws-cloudwatch"; import { Table } from "aws-cdk-lib/aws-dynamodb"; +import { Function } from "aws-cdk-lib/aws-lambda"; import { Topic } from "aws-cdk-lib/aws-sns"; import { DefaultDashboardFactory, @@ -92,6 +93,7 @@ describe("test of defaults", () => { action: notifySns(onAlarmTopic), }, }); + facade .addLargeHeader("My App Dashboard") .monitorDynamoTable({ @@ -110,11 +112,18 @@ describe("test of defaults", () => { ), region: "us-west-2", account: "01234567890", - addAverageSuccessfulGetItemLatencyAlarm: { - Critical: { - maxLatency: Duration.seconds(10), + }) + .monitorLambdaFunction({ + account: "01234567890", + region: "us-west-2", + lambdaFunction: Function.fromFunctionAttributes( + stack, + "XaXrImportedFunction", + { + functionArn: `arn:aws:lambda:us-west-2:01234567890:function:MyFunction`, + sameEnvironment: false, }, - }, + ), }); expect(Template.fromStack(stack)).toMatchSnapshot(); diff --git a/test/facade/__snapshots__/MonitoringAspect.test.ts.snap b/test/facade/__snapshots__/MonitoringAspect.test.ts.snap index cfa5c01f..fa485bc5 100644 --- a/test/facade/__snapshots__/MonitoringAspect.test.ts.snap +++ b/test/facade/__snapshots__/MonitoringAspect.test.ts.snap @@ -2070,7 +2070,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, @@ -2152,7 +2152,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, @@ -9216,11 +9216,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Allowed\\",\\"region\\":\\"", - Object { - "Ref": "AWS::Region", - }, - "\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":8,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Blocked Requests\\",\\"region\\":\\"", + "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Allowed\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":8,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Blocked Requests\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -9228,11 +9224,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Blocked\\",\\"region\\":\\"", - Object { - "Ref": "AWS::Region", - }, - "\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":16,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Blocked Requests (rate)\\",\\"region\\":\\"", + "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Blocked\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":16,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Blocked Requests (rate)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -9240,19 +9232,11 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Allowed\\",\\"region\\":\\"", - Object { - "Ref": "AWS::Region", - }, - "\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"allowed\\"}],[\\"AWS/WAFV2\\",\\"BlockedRequests\\",\\"Region\\",\\"", - Object { - "Ref": "AWS::Region", - }, - "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Blocked\\",\\"region\\":\\"", + "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Allowed\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"allowed\\"}],[\\"AWS/WAFV2\\",\\"BlockedRequests\\",\\"Region\\",\\"", Object { "Ref": "AWS::Region", }, - "\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"blocked\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Blocked\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"blocked\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -9274,11 +9258,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Allowed\\",\\"region\\":\\"", - Object { - "Ref": "AWS::Region", - }, - "\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":8,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Blocked Requests\\",\\"region\\":\\"", + "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Allowed\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":8,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Blocked Requests\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -9286,11 +9266,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Blocked\\",\\"region\\":\\"", - Object { - "Ref": "AWS::Region", - }, - "\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":16,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Blocked Requests (rate)\\",\\"region\\":\\"", + "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Blocked\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":6,\\"x\\":16,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Blocked Requests (rate)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -9298,19 +9274,11 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Allowed\\",\\"region\\":\\"", - Object { - "Ref": "AWS::Region", - }, - "\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"allowed\\"}],[\\"AWS/WAFV2\\",\\"BlockedRequests\\",\\"Region\\",\\"", - Object { - "Ref": "AWS::Region", - }, - "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Blocked\\",\\"region\\":\\"", + "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Allowed\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"allowed\\"}],[\\"AWS/WAFV2\\",\\"BlockedRequests\\",\\"Region\\",\\"", Object { "Ref": "AWS::Region", }, - "\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"blocked\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"Rule\\",\\"ALL\\",{\\"label\\":\\"Blocked\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"blocked\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, diff --git a/test/facade/__snapshots__/MonitoringFacade.test.ts.snap b/test/facade/__snapshots__/MonitoringFacade.test.ts.snap index 065dec82..e4385a69 100644 --- a/test/facade/__snapshots__/MonitoringFacade.test.ts.snap +++ b/test/facade/__snapshots__/MonitoringFacade.test.ts.snap @@ -40,15 +40,15 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Consumed\\",\\"expression\\":\\"consumed_rcu_sum/PERIOD(consumed_rcu_sum)\\",\\"accountId\\":\\"09876543210\\",\\"region\\":\\"us-east-1\\",\\"id\\":\\"consumed_read_cap\\"}],[\\"AWS/DynamoDB\\",\\"ConsumedReadCapacityUnits\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"consumed_rcu_sum\\"}],[\\"AWS/DynamoDB\\",\\"ProvisionedReadCapacityUnits\\",\\"TableName\\",\\"my-other-table\\",{\\"label\\":\\"Provisioned\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"id\\":\\"provisioned_read_cap\\"}],[{\\"label\\":\\"Utilization\\",\\"expression\\":\\"100*(consumed_read_cap/provisioned_read_cap)\\",\\"accountId\\":\\"09876543210\\",\\"region\\":\\"us-east-1\\",\\"yAxis\\":\\"right\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false},\\"right\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}},\\"legend\\":{\\"position\\":\\"right\\"}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":3,\\"x\\":0,\\"y\\":12,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Write Usage\\",\\"region\\":\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Consumed\\",\\"expression\\":\\"consumed_rcu_sum/PERIOD(consumed_rcu_sum)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"id\\":\\"consumed_read_cap\\"}],[\\"AWS/DynamoDB\\",\\"ConsumedReadCapacityUnits\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"consumed_rcu_sum\\"}],[\\"AWS/DynamoDB\\",\\"ProvisionedReadCapacityUnits\\",\\"TableName\\",\\"my-other-table\\",{\\"label\\":\\"Provisioned\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"id\\":\\"provisioned_read_cap\\"}],[{\\"label\\":\\"Utilization\\",\\"expression\\":\\"100*(consumed_read_cap/provisioned_read_cap)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"yAxis\\":\\"right\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false},\\"right\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}},\\"legend\\":{\\"position\\":\\"right\\"}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":3,\\"x\\":0,\\"y\\":12,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Write Usage\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Consumed\\",\\"expression\\":\\"consumed_wcu_sum/PERIOD(consumed_wcu_sum)\\",\\"accountId\\":\\"09876543210\\",\\"region\\":\\"us-east-1\\",\\"id\\":\\"consumed_write_cap\\"}],[\\"AWS/DynamoDB\\",\\"ConsumedWriteCapacityUnits\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"consumed_wcu_sum\\"}],[\\"AWS/DynamoDB\\",\\"ProvisionedWriteCapacityUnits\\",\\"TableName\\",\\"my-other-table\\",{\\"label\\":\\"Provisioned\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"id\\":\\"provisioned_write_cap\\"}],[{\\"label\\":\\"Utilization\\",\\"expression\\":\\"100*(consumed_write_cap/provisioned_write_cap)\\",\\"accountId\\":\\"09876543210\\",\\"region\\":\\"us-east-1\\",\\"yAxis\\":\\"right\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false},\\"right\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}},\\"legend\\":{\\"position\\":\\"right\\"}}},{\\"type\\":\\"metric\\",\\"width\\":9,\\"height\\":6,\\"x\\":6,\\"y\\":9,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Latency (Average)\\",\\"region\\":\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Consumed\\",\\"expression\\":\\"consumed_wcu_sum/PERIOD(consumed_wcu_sum)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"id\\":\\"consumed_write_cap\\"}],[\\"AWS/DynamoDB\\",\\"ConsumedWriteCapacityUnits\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"consumed_wcu_sum\\"}],[\\"AWS/DynamoDB\\",\\"ProvisionedWriteCapacityUnits\\",\\"TableName\\",\\"my-other-table\\",{\\"label\\":\\"Provisioned\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"id\\":\\"provisioned_write_cap\\"}],[{\\"label\\":\\"Utilization\\",\\"expression\\":\\"100*(consumed_write_cap/provisioned_write_cap)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"yAxis\\":\\"right\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false},\\"right\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}},\\"legend\\":{\\"position\\":\\"right\\"}}},{\\"type\\":\\"metric\\",\\"width\\":9,\\"height\\":6,\\"x\\":6,\\"y\\":9,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Latency (Average)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\" \\",\\"expression\\":\\"SEARCH('{AWS/DynamoDB,TableName,Operation} TableName=\\\\\\"my-other-table\\\\\\" MetricName=\\\\\\"SuccessfulRequestLatency\\\\\\"', 'Average', 300)\\",\\"accountId\\":\\"09876543210\\",\\"region\\":\\"us-east-1\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"GetItem > 10000 for 3 datapoints within 15 minutes\\",\\"value\\":10000,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"ms\\",\\"showUnits\\":false}},\\"legend\\":{\\"position\\":\\"right\\"}}},{\\"type\\":\\"metric\\",\\"width\\":3,\\"height\\":6,\\"x\\":15,\\"y\\":9,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Throttles\\",\\"region\\":\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\" \\",\\"expression\\":\\"SEARCH('{AWS/DynamoDB,TableName,Operation} TableName=\\\\\\"my-other-table\\\\\\" MetricName=\\\\\\"SuccessfulRequestLatency\\\\\\"', 'Average', 300)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"ms\\",\\"showUnits\\":false}},\\"legend\\":{\\"position\\":\\"right\\"}}},{\\"type\\":\\"metric\\",\\"width\\":3,\\"height\\":6,\\"x\\":15,\\"y\\":9,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Throttles\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -56,7 +56,35 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"System Errors\\",\\"expression\\":\\"systemErrorGetItem+systemErrorBatchGetItem+systemErrorScan+systemErrorQuery+systemErrorGetRecords+systemErrorPutItem+systemErrorDeleteItem+systemErrorUpdateItem+systemErrorBatchWriteItem\\",\\"accountId\\":\\"09876543210\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"GetItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorGetItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"BatchGetItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorBatchGetItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"Scan\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorScan\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"Query\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorQuery\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"GetRecords\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorGetRecords\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"PutItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorPutItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"DeleteItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorDeleteItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"UpdateItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorUpdateItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"BatchWriteItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorBatchWriteItem\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}}]}", + "\\",\\"metrics\\":[[{\\"label\\":\\"System Errors\\",\\"expression\\":\\"systemErrorGetItem+systemErrorBatchGetItem+systemErrorScan+systemErrorQuery+systemErrorGetRecords+systemErrorPutItem+systemErrorDeleteItem+systemErrorUpdateItem+systemErrorBatchWriteItem\\",\\"accountId\\":\\"09876543210\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"GetItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorGetItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"BatchGetItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorBatchGetItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"Scan\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorScan\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"Query\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorQuery\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"GetRecords\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorGetRecords\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"PutItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorPutItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"DeleteItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorDeleteItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"UpdateItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorUpdateItem\\"}],[\\"AWS/DynamoDB\\",\\"SystemErrors\\",\\"Operation\\",\\"BatchWriteItem\\",\\"TableName\\",\\"my-other-table\\",{\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"systemErrorBatchWriteItem\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"text\\",\\"width\\":24,\\"height\\":1,\\"x\\":0,\\"y\\":15,\\"properties\\":{\\"markdown\\":\\"### Lambda Function **[XaXrImportedFunction](https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions/MyFunction)**\\"}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":0,\\"y\\":16,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"TPS\\",\\"region\\":\\"", + Object { + "Ref": "AWS::Region", + }, + "\\",\\"metrics\\":[[{\\"label\\":\\"TPS\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\"}],[\\"AWS/Lambda\\",\\"Invocations\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Invocations\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":6,\\"y\\":16,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Latency\\",\\"region\\":\\"", + Object { + "Ref": "AWS::Region", + }, + "\\",\\"metrics\\":[[\\"AWS/Lambda\\",\\"Duration\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"P50 (avg: \${AVG})\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"p50\\"}],[\\"AWS/Lambda\\",\\"Duration\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"P90 (avg: \${AVG})\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"p90\\"}],[\\"AWS/Lambda\\",\\"Duration\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"P99 (avg: \${AVG})\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"p99\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"ms\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":12,\\"y\\":16,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", + Object { + "Ref": "AWS::Region", + }, + "\\",\\"metrics\\":[[\\"AWS/Lambda\\",\\"Errors\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Faults (avg)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":18,\\"y\\":16,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Rates\\",\\"region\\":\\"", + Object { + "Ref": "AWS::Region", + }, + "\\",\\"metrics\\":[[\\"AWS/Lambda\\",\\"Throttles\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Throttles (avg)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\"}],[\\"AWS/Lambda\\",\\"ProvisionedConcurrencySpilloverInvocations\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Provisioned Concurrency Spillovers (avg)\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":0,\\"y\\":21,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Invocations\\",\\"region\\":\\"", + Object { + "Ref": "AWS::Region", + }, + "\\",\\"metrics\\":[[\\"AWS/Lambda\\",\\"Invocations\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Invocations\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/Lambda\\",\\"Throttles\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Throttles\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/Lambda\\",\\"ConcurrentExecutions\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Concurrent\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Maximum\\"}],[\\"AWS/Lambda\\",\\"ProvisionedConcurrencySpilloverInvocations\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Provisioned Concurrency Spillovers\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":8,\\"y\\":21,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Iterator\\",\\"region\\":\\"", + Object { + "Ref": "AWS::Region", + }, + "\\",\\"metrics\\":[[\\"AWS/Lambda\\",\\"IteratorAge\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Iterator Age\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Maximum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"ms\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":16,\\"y\\":21,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors\\",\\"region\\":\\"", + Object { + "Ref": "AWS::Region", + }, + "\\",\\"metrics\\":[[\\"AWS/Lambda\\",\\"Errors\\",\\"FunctionName\\",\\"MyFunction\\",{\\"label\\":\\"Faults\\",\\"accountId\\":\\"01234567890\\",\\"region\\":\\"us-west-2\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Count\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -107,50 +135,6 @@ Object { }, "Type": "AWS::CloudWatch::Alarm", }, - "MyAppFacadeMyAppXaXrImportedTableLatencyAverageGetItemCritical3480F8E9": Object { - "Properties": Object { - "ActionsEnabled": true, - "AlarmActions": Array [ - Object { - "Ref": "OnAlarmTopicF22649A2", - }, - ], - "AlarmDescription": "Average latency is too high.", - "AlarmName": "MyApp-XaXrImportedTable-Latency-Average-GetItem-Critical", - "ComparisonOperator": "GreaterThanThreshold", - "DatapointsToAlarm": 3, - "EvaluationPeriods": 3, - "Metrics": Array [ - Object { - "AccountId": "01234567890", - "Id": "m1", - "Label": "GetItem", - "MetricStat": Object { - "Metric": Object { - "Dimensions": Array [ - Object { - "Name": "Operation", - "Value": "GetItem", - }, - Object { - "Name": "TableName", - "Value": "my-other-table", - }, - ], - "MetricName": "SuccessfulRequestLatency", - "Namespace": "AWS/DynamoDB", - }, - "Period": 300, - "Stat": "Average", - }, - "ReturnData": true, - }, - ], - "Threshold": 10000, - "TreatMissingData": "notBreaching", - }, - "Type": "AWS::CloudWatch::Alarm", - }, "OnAlarmTopicF22649A2": Object { "Properties": Object { "TopicName": "Alarm", diff --git a/test/monitoring/TestMonitoringScope.ts b/test/monitoring/TestMonitoringScope.ts index 69665d81..a9857b11 100644 --- a/test/monitoring/TestMonitoringScope.ts +++ b/test/monitoring/TestMonitoringScope.ts @@ -64,7 +64,10 @@ export class TestMonitoringScope extends MonitoringScope { } createMetricFactory(): MetricFactory { - return new MetricFactory({ globalDefaults: DummyGlobalMetricDefaults }); + return new MetricFactory( + { globalDefaults: DummyGlobalMetricDefaults }, + this, + ); } createWidgetFactory(): IWidgetFactory { diff --git a/test/monitoring/aws-cloudfront/CloudFrontDistribution.test.ts b/test/monitoring/aws-cloudfront/CloudFrontDistribution.test.ts index d593906b..27707edd 100644 --- a/test/monitoring/aws-cloudfront/CloudFrontDistribution.test.ts +++ b/test/monitoring/aws-cloudfront/CloudFrontDistribution.test.ts @@ -33,7 +33,11 @@ import { TestMonitoringScope } from "../TestMonitoringScope"; }); test(`snapshot test: all alarms with additionalMetricsEnabled=${additionalMetricsEnabled}`, () => { - const stack = new Stack(); + const stack = new Stack(undefined, undefined, { + env: { + region: "us-east-1", + }, + }); const bucket = new Bucket(stack, "Bucket"); const distribution = new Distribution(stack, "Distribution", { defaultBehavior: { diff --git a/test/monitoring/aws-cloudfront/__snapshots__/CloudFrontDistribution.test.ts.snap b/test/monitoring/aws-cloudfront/__snapshots__/CloudFrontDistribution.test.ts.snap index c7cf8f62..731cc979 100644 --- a/test/monitoring/aws-cloudfront/__snapshots__/CloudFrontDistribution.test.ts.snap +++ b/test/monitoring/aws-cloudfront/__snapshots__/CloudFrontDistribution.test.ts.snap @@ -177,7 +177,7 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":8,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Traffic\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":8,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Traffic\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -185,11 +185,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Downloaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/CloudFront\\",\\"BytesUploaded\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Downloaded\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/CloudFront\\",\\"BytesUploaded\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"bytes\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":16,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"bytes\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":8,\\"height\\":5,\\"x\\":16,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -197,11 +197,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\",\\"region\\":\\"us-east-1\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -396,7 +396,7 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":12,\\"height\\":6,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":12,\\"height\\":6,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -404,11 +404,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\",\\"region\\":\\"us-east-1\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -623,7 +623,7 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":6,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Hit Rate\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":6,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Hit Rate\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -631,7 +631,7 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Hit Rate\\",\\"region\\":\\"us-east-1\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Traffic\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Hit Rate\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Traffic\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -639,11 +639,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Downloaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/CloudFront\\",\\"BytesUploaded\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Downloaded\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/CloudFront\\",\\"BytesUploaded\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"bytes\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"bytes\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -651,11 +651,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\",\\"region\\":\\"us-east-1\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -850,7 +850,7 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":12,\\"height\\":6,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":12,\\"height\\":6,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -858,11 +858,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\",\\"region\\":\\"us-east-1\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -1077,7 +1077,7 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":6,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Hit Rate\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":6,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Hit Rate\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -1085,7 +1085,7 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Hit Rate\\",\\"region\\":\\"us-east-1\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Traffic\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Hit Rate\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"max\\":100,\\"label\\":\\"%\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Traffic\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -1093,11 +1093,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Downloaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/CloudFront\\",\\"BytesUploaded\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Downloaded\\",\\"stat\\":\\"Sum\\"}],[\\"AWS/CloudFront\\",\\"BytesUploaded\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"bytes\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"bytes\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":6,\\"height\\":5,\\"x\\":18,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -1105,11 +1105,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\",\\"region\\":\\"us-east-1\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -1304,7 +1304,7 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":12,\\"height\\":6,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"Uploaded\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"requests\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"Uploaded/s < 10 for 3 datapoints within 15 minutes\\",\\"value\\":10,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"Uploaded/s > 20 for 3 datapoints within 15 minutes\\",\\"value\\":20,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}},{\\"type\\":\\"metric\\",\\"width\\":12,\\"height\\":6,\\"x\\":12,\\"y\\":1,\\"properties\\":{\\"view\\":\\"timeSeries\\",\\"title\\":\\"Errors (rate)\\",\\"region\\":\\"", Object { "Ref": "AWS::Region", }, @@ -1312,11 +1312,11 @@ Object { Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"4XX\\"}],[\\"AWS/CloudFront\\",\\"5xxErrorRate\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, - "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\",\\"region\\":\\"us-east-1\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"Region\\",\\"Global\\",{\\"label\\":\\"5XX\\"}]],\\"annotations\\":{\\"horizontal\\":[{\\"label\\":\\"4XX > 0.5 for 3 datapoints within 15 minutes\\",\\"value\\":0.5,\\"yAxis\\":\\"left\\"},{\\"label\\":\\"5XX > 0.8 for 3 datapoints within 15 minutes\\",\\"value\\":0.8,\\"yAxis\\":\\"left\\"}]},\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -1476,7 +1476,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, @@ -1525,7 +1525,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, @@ -1701,7 +1701,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, @@ -1758,7 +1758,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, @@ -1934,7 +1934,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, @@ -1991,7 +1991,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", + "\\",\\"metrics\\":[[{\\"label\\":\\"Uploaded/s\\",\\"expression\\":\\"FILL(requests,0) / PERIOD(requests)\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/CloudFront\\",\\"Requests\\",\\"DistributionId\\",\\"", Object { "Ref": "Distribution830FAC52", }, diff --git a/test/monitoring/aws-wafv2/__snapshots__/WafV2Monitoring.test.ts.snap b/test/monitoring/aws-wafv2/__snapshots__/WafV2Monitoring.test.ts.snap index 99d0db60..46b864cf 100644 --- a/test/monitoring/aws-wafv2/__snapshots__/WafV2Monitoring.test.ts.snap +++ b/test/monitoring/aws-wafv2/__snapshots__/WafV2Monitoring.test.ts.snap @@ -294,7 +294,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Blocked (rate)\\",\\"expression\\":\\"100 * (blocked / (allowed + blocked))\\"}],[\\"AWS/WAFV2\\",\\"AllowedRequests\\",\\"Region\\",\\"us-east-1\\",\\"Rule\\",\\"ALL\\",\\"WebACL\\",\\"DummyAclName\\",{\\"label\\":\\"Allowed\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"allowed\\"}],[\\"AWS/WAFV2\\",\\"BlockedRequests\\",\\"Region\\",\\"us-east-1\\",\\"Rule\\",\\"ALL\\",\\"WebACL\\",\\"DummyAclName\\",{\\"label\\":\\"Blocked\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"blocked\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"metrics\\":[[{\\"label\\":\\"Blocked (rate)\\",\\"expression\\":\\"100 * (blocked / (allowed + blocked))\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/WAFV2\\",\\"AllowedRequests\\",\\"Region\\",\\"us-east-1\\",\\"Rule\\",\\"ALL\\",\\"WebACL\\",\\"DummyAclName\\",{\\"label\\":\\"Allowed\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"allowed\\"}],[\\"AWS/WAFV2\\",\\"BlockedRequests\\",\\"Region\\",\\"us-east-1\\",\\"Rule\\",\\"ALL\\",\\"WebACL\\",\\"DummyAclName\\",{\\"label\\":\\"Blocked\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"blocked\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, @@ -319,7 +319,7 @@ Object { Object { "Ref": "AWS::Region", }, - "\\",\\"metrics\\":[[{\\"label\\":\\"Blocked (rate)\\",\\"expression\\":\\"100 * (blocked / (allowed + blocked))\\"}],[\\"AWS/WAFV2\\",\\"AllowedRequests\\",\\"Region\\",\\"us-east-1\\",\\"Rule\\",\\"ALL\\",\\"WebACL\\",\\"DummyAclName\\",{\\"label\\":\\"Allowed\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"allowed\\"}],[\\"AWS/WAFV2\\",\\"BlockedRequests\\",\\"Region\\",\\"us-east-1\\",\\"Rule\\",\\"ALL\\",\\"WebACL\\",\\"DummyAclName\\",{\\"label\\":\\"Blocked\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"blocked\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", + "\\",\\"metrics\\":[[{\\"label\\":\\"Blocked (rate)\\",\\"expression\\":\\"100 * (blocked / (allowed + blocked))\\",\\"region\\":\\"us-east-1\\"}],[\\"AWS/WAFV2\\",\\"AllowedRequests\\",\\"Region\\",\\"us-east-1\\",\\"Rule\\",\\"ALL\\",\\"WebACL\\",\\"DummyAclName\\",{\\"label\\":\\"Allowed\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"allowed\\"}],[\\"AWS/WAFV2\\",\\"BlockedRequests\\",\\"Region\\",\\"us-east-1\\",\\"Rule\\",\\"ALL\\",\\"WebACL\\",\\"DummyAclName\\",{\\"label\\":\\"Blocked\\",\\"region\\":\\"us-east-1\\",\\"stat\\":\\"Sum\\",\\"visible\\":false,\\"id\\":\\"blocked\\"}]],\\"yAxis\\":{\\"left\\":{\\"min\\":0,\\"label\\":\\"Rate\\",\\"showUnits\\":false}}}}]}", ], ], }, diff --git a/test/monitoring/custom/CustomMonitoring.test.ts b/test/monitoring/custom/CustomMonitoring.test.ts index 2888e240..a6138497 100644 --- a/test/monitoring/custom/CustomMonitoring.test.ts +++ b/test/monitoring/custom/CustomMonitoring.test.ts @@ -244,11 +244,14 @@ test("addToSummaryDashboard attribute takes value from CustomMonitoringProps if test("anomaly detection", () => { const stack = new Stack(); - const metricFactory = new MetricFactory({ - globalDefaults: { - namespace: "AnomalyNamespace", + const metricFactory = new MetricFactory( + { + globalDefaults: { + namespace: "AnomalyNamespace", + }, }, - }); + stack, + ); const scope = new TestMonitoringScope(stack, "Scope");