Skip to content

Commit 892b013

Browse files
authored
fix(logs): exposed metric from the metric filter will now include the dimension map (#34648)
### Issue # (if applicable) Closes #34643 ### Reason for this change When the metric filter is created, you can specify the dimension map for the metric. When you extract the metric out of the metric filter, the extracted metric will not include the dimension map, and you will be forced to manually add it to the metric. ### Description of changes This PR preserves the dimension map used when creating the metric filter and then applies it back when extracting the metric using the `MetricFilter.metric()` API. ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Added new unit and integration test that verify the extracted metric still includes the original dimension map used when creating the metric filter. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 89c5350 commit 892b013

13 files changed

+448
-37
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.expose-metric-with-dimensions.js.snapshot/aws-cdk-expose-metric-with-dimensions-integ.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"Resources": {
3+
"LogGroupF5B46931": {
4+
"Type": "AWS::Logs::LogGroup",
5+
"Properties": {
6+
"RetentionInDays": 731
7+
},
8+
"UpdateReplacePolicy": "Retain",
9+
"DeletionPolicy": "Retain"
10+
},
11+
"MetricFilter1B93B6E5": {
12+
"Type": "AWS::Logs::MetricFilter",
13+
"Properties": {
14+
"FilterPattern": "{ $.latency = \"*\" }",
15+
"LogGroupName": {
16+
"Ref": "LogGroupF5B46931"
17+
},
18+
"MetricTransformations": [
19+
{
20+
"Dimensions": [
21+
{
22+
"Key": "Foo",
23+
"Value": "Bar"
24+
},
25+
{
26+
"Key": "Bar",
27+
"Value": "Baz"
28+
}
29+
],
30+
"MetricName": "testName",
31+
"MetricNamespace": "testNamespace",
32+
"MetricValue": "$.latency"
33+
}
34+
]
35+
}
36+
},
37+
"Dashboard9E4231ED": {
38+
"Type": "AWS::CloudWatch::Dashboard",
39+
"Properties": {
40+
"DashboardBody": {
41+
"Fn::Join": [
42+
"",
43+
[
44+
"{\"widgets\":[{\"type\":\"metric\",\"width\":6,\"height\":6,\"x\":0,\"y\":0,\"properties\":{\"view\":\"timeSeries\",\"title\":\"Latency with Dimensions\",\"region\":\"",
45+
{
46+
"Ref": "AWS::Region"
47+
},
48+
"\",\"metrics\":[[\"testNamespace\",\"testName\",\"Bar\",\"Baz\",\"Foo\",\"Bar\"]],\"yAxis\":{}}}]}"
49+
]
50+
]
51+
},
52+
"DashboardName": "ExposeMetricWithDimensionsDashboard"
53+
}
54+
}
55+
},
56+
"Parameters": {
57+
"BootstrapVersion": {
58+
"Type": "AWS::SSM::Parameter::Value<String>",
59+
"Default": "/cdk-bootstrap/hnb659fds/version",
60+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
61+
}
62+
},
63+
"Rules": {
64+
"CheckBootstrapVersion": {
65+
"Assertions": [
66+
{
67+
"Assert": {
68+
"Fn::Not": [
69+
{
70+
"Fn::Contains": [
71+
[
72+
"1",
73+
"2",
74+
"3",
75+
"4",
76+
"5"
77+
],
78+
{
79+
"Ref": "BootstrapVersion"
80+
}
81+
]
82+
}
83+
]
84+
},
85+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
86+
}
87+
]
88+
}
89+
}
90+
}

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.expose-metric-with-dimensions.js.snapshot/awscdkexposemetricwithdimensionsintegExposeMetricWithDimensionsTestDefaultTestDeployAssert42449B59.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.expose-metric-with-dimensions.js.snapshot/awscdkexposemetricwithdimensionsintegExposeMetricWithDimensionsTestDefaultTestDeployAssert42449B59.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.expose-metric-with-dimensions.js.snapshot/cdk.out

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.expose-metric-with-dimensions.js.snapshot/integ.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.expose-metric-with-dimensions.js.snapshot/manifest.json

Lines changed: 182 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.expose-metric-with-dimensions.js.snapshot/tree.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)