Skip to content

Commit

Permalink
feat(cloudfront): retrieve default distribution metrics (#28894)
Browse files Browse the repository at this point in the history
This PR implements functions to retrieve [default distribution metrics](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/viewing-cloudfront-metrics.html).

```ts
declare const dist: cloudfront.Distribution

const metric = dist.metricRequests()
```

Closes #28893

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
badmintoncryer authored and SankyRed committed Feb 8, 2024
1 parent 6888939 commit 133e399
Show file tree
Hide file tree
Showing 12 changed files with 941 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"Resources": {
"DistB3B78991": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"DefaultCacheBehavior": {
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"TargetOriginId": "MyTestStackDistOrigin1CBA48A7B",
"ViewerProtocolPolicy": "allow-all"
},
"Enabled": true,
"HttpVersion": "http2",
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
},
"DomainName": "www.example.com",
"Id": "MyTestStackDistOrigin1CBA48A7B"
}
]
}
}
},
"Alarm1F9009D71": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ComparisonOperator": "GreaterThanThreshold",
"Dimensions": [
{
"Name": "DistributionId",
"Value": {
"Ref": "DistB3B78991"
}
}
],
"EvaluationPeriods": 1,
"MetricName": "Requests",
"Namespace": "AWS/CloudFront",
"Period": 300,
"Statistic": "Sum",
"Threshold": 1
}
},
"Alarm2A7122E13": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ComparisonOperator": "GreaterThanThreshold",
"Dimensions": [
{
"Name": "DistributionId",
"Value": {
"Ref": "DistB3B78991"
}
}
],
"EvaluationPeriods": 1,
"MetricName": "BytesUploaded",
"Namespace": "AWS/CloudFront",
"Period": 300,
"Statistic": "Sum",
"Threshold": 1
}
},
"Alarm32341D8D9": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ComparisonOperator": "GreaterThanThreshold",
"Dimensions": [
{
"Name": "DistributionId",
"Value": {
"Ref": "DistB3B78991"
}
}
],
"EvaluationPeriods": 1,
"MetricName": "BytesDownloaded",
"Namespace": "AWS/CloudFront",
"Period": 300,
"Statistic": "Sum",
"Threshold": 1
}
},
"Alarm4671832C8": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ComparisonOperator": "GreaterThanThreshold",
"Dimensions": [
{
"Name": "DistributionId",
"Value": {
"Ref": "DistB3B78991"
}
}
],
"EvaluationPeriods": 1,
"MetricName": "4xxErrorRate",
"Namespace": "AWS/CloudFront",
"Period": 300,
"Statistic": "Average",
"Threshold": 1
}
},
"Alarm548383B2F": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ComparisonOperator": "GreaterThanThreshold",
"Dimensions": [
{
"Name": "DistributionId",
"Value": {
"Ref": "DistB3B78991"
}
}
],
"EvaluationPeriods": 1,
"MetricName": "5xxErrorRate",
"Namespace": "AWS/CloudFront",
"Period": 300,
"Statistic": "Average",
"Threshold": 1
}
},
"Alarm65738D89F": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"ComparisonOperator": "GreaterThanThreshold",
"Dimensions": [
{
"Name": "DistributionId",
"Value": {
"Ref": "DistB3B78991"
}
}
],
"EvaluationPeriods": 1,
"MetricName": "TotalErrorRate",
"Namespace": "AWS/CloudFront",
"Period": 300,
"Statistic": "Average",
"Threshold": 1
}
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 133e399

Please sign in to comment.