aws-cdk/aws-logs: Cannot add dimensions to MetricFilter
See original GitHub issueDescription
It is possible to add dimensions to a metric filter via the console, but this functionality does not seem to be carried through into CDK.
I expected to be able to add dimensions via metric filter props, but I could only add them to the metric itself and that did not work:
const metric = new CW.Metric({
namespace: "demoNs",
metricName: "demoMetric",
dimensions: { Type: "$.type" },
});
new Logs.MetricFilter(this, `MetricFilter`, {
metricName: "demoMetric",
metricNamespace: "demoNs",
logGroup: props.logGroup,
filterPattern: Logs.FilterPattern.all(
Logs.FilterPattern.stringValue("$.category", "==", "metric"),
Logs.FilterPattern.stringValue("$.name", "==", "success")
),
metricValue: "1",
});
There is no mention of dimensions at all in the documentation: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.MetricFilter.html
Use Case
Currently I need to create separate metric filters for each dimension, which is not optimal.
Proposed Solution
const metric = new CW.Metric({
namespace: "demoNs",
metricName: "demoMetric"
});
new Logs.MetricFilter(this, `MetricFilter`, {
metricName: "demoMetric",
metricNamespace: "demoNs",
logGroup: props.logGroup,
filterPattern: Logs.FilterPattern.all(
Logs.FilterPattern.stringValue("$.category", "==", "metric"),
Logs.FilterPattern.stringValue("$.name", "==", "success")
),
metricValue: "1",
dimensions: { Type: "$.type" },
});
Other information
No response
Acknowledge
- I may be able to implement this feature request
- This feature might incur a breaking change
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:10 (6 by maintainers)
Top Results From Across the Web
class MetricFilter (construct) · AWS CDK
A filter that extracts information from CloudWatch Logs and emits to CloudWatch Metrics. Example. new MetricFilter(this, 'MetricFilter', { logGroup, ...
Read more >AWS CDK 101 - Cloudwatch Metrics Filter with Dimensions ...
A Metric filter is created on top of a specific log group so that the log streams will be digested and metrics will...
Read more >@aws-cdk/aws-logs - npm
A very simple MetricFilter can be created by using the logGroup. extractMetric() helper function: declare const logGroup: logs.
Read more >@aws-cdk/aws-logs | Yarn - Package Manager
@aws-cdk/aws-logs. owner aws3.9mApache-2.01.182.0TS vulns 0 vulnerabilities. The CDK Construct Library for AWS::Logs. aws, cdk, constructs, logs ...
Read more >PutMetricFilter - Amazon CloudWatch Logs - 亚马逊云科技
When you create a metric filter, you can also optionally assign a unit and dimensions to the metric that is created. Important. Metrics...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Until dimension support is added to CloudFormation and CDK, you can use this construct:
Example usage:
Thanks @seyeong, i opened a PR to implement this #21654