(cloudwatch): CloudFront alarm doesn't reference metrics emitted from the service
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### What is the problem?
When creating an alarm from CloudFront metrics, the metrics do not reference the actual metrics emitted from the service and therefore are not accurate.
Related: https://github.com/aws/aws-cdk/issues/1739.
### Reproduction Steps
```
const metric = new cloudwatch.Metric({
namespace: `AWS/CloudFront`,
metricName: 'TotalErrorRate',
region: 'global', // tried 'Global' as well
statistic: 'SUM',
period: cdk.Duration.minutes(1),
dimensions: { DistributionId: `${distro.id}` }
})
const alarm = new cloudwatch.Alarm(this, `CloudFront_TotalErrorRate_${distro.id}`, {
metric
...
```
This creates an alarm that looks like the following: https://user-images.githubusercontent.com/3310356/156422019-4ff03b77-a0f8-40fe-aea6-6dd3dda3cb35.png.
However, the graph shown by the metrics do not match the metrics shown in the CloudFront console.
I created an alarm manually from the actual CloudFront metrics and get the following: https://user-images.githubusercontent.com/3310356/156421997-d83a94e5-2a2d-4df2-8ab7-dab47922a935.png.
### What did you expect to happen?
Alarm and metrics matching the metrics emitted from the CloudFront service.
### What actually happened?
Alarm with metrics that don't match the emitted metrics from CloudFront.
### CDK CLI Version
2.10.0 (build e5b301f)
### Framework Version
_No response_
### Node.js Version
v14.18.1
### OS
macOS Big Sur v11.6.1
### Language
Typescript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start with the CloudFront metric and alarm reproduction in the issue, then compare the generated alarm metrics with the metrics emitted by the CloudFront service and shown in the CloudFront console. Done means the CDK-created alarm references the same metrics and produces matching graphs; the related issue may provide additional context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100