Skip to content

Commit effa46d

Browse files
authored
feat(logs): add parameter to allow metric filter on transformed logs (#35359)
### Issue # (if applicable) Not related to any issue. ### Reason for this change It was not possible to pass the argument 'applyOnTransformedLogs' to the class MetricFilter, in order to create MetricFilter, Filter and Alarm. ### Description of changes Since MetricFilter makes use of CfnMetricFilter, which allows the parameter 'applyOnTransformedLogs', this change adds the parameter 'applyOnTransformedLogs' to MetricFilterOptions, which is directly passed to the CfnMetric class. ### Describe any new or updated permissions being added No permission is added or updated. ### Description of how you validated changes I tested by hand. ### 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 4b4e322 commit effa46d

13 files changed

+871
-0
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter-apply-on-transformed-logs.js.snapshot/aws-cdk-metricfilter-apply-on-transformed-logs-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,63 @@
1+
{
2+
"Resources": {
3+
"LogGroupF5B46931": {
4+
"Type": "AWS::Logs::LogGroup",
5+
"Properties": {
6+
"RetentionInDays": 731
7+
},
8+
"UpdateReplacePolicy": "Delete",
9+
"DeletionPolicy": "Delete"
10+
},
11+
"MetricFilter1B93B6E5": {
12+
"Type": "AWS::Logs::MetricFilter",
13+
"Properties": {
14+
"ApplyOnTransformedLogs": true,
15+
"FilterPattern": "{ $.latency = \"*\" }",
16+
"LogGroupName": {
17+
"Ref": "LogGroupF5B46931"
18+
},
19+
"MetricTransformations": [
20+
{
21+
"MetricName": "Latency",
22+
"MetricNamespace": "MyApp",
23+
"MetricValue": "1"
24+
}
25+
]
26+
}
27+
}
28+
},
29+
"Parameters": {
30+
"BootstrapVersion": {
31+
"Type": "AWS::SSM::Parameter::Value<String>",
32+
"Default": "/cdk-bootstrap/hnb659fds/version",
33+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
34+
}
35+
},
36+
"Rules": {
37+
"CheckBootstrapVersion": {
38+
"Assertions": [
39+
{
40+
"Assert": {
41+
"Fn::Not": [
42+
{
43+
"Fn::Contains": [
44+
[
45+
"1",
46+
"2",
47+
"3",
48+
"4",
49+
"5"
50+
],
51+
{
52+
"Ref": "BootstrapVersion"
53+
}
54+
]
55+
}
56+
]
57+
},
58+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
59+
}
60+
]
61+
}
62+
}
63+
}

packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter-apply-on-transformed-logs.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.metricfilter-apply-on-transformed-logs.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.

0 commit comments

Comments
 (0)