Skip to content

(cloudfront): Flag on Distribution L2 to enable publishing additional CloudWatch metrics #22922

@straygar

Description

@straygar

Describe the feature

The CloudFront UI and API lets you enable more granular metrics per-distribution, at an additional (fixed) cost.

There is an L1 construct that lets you do this, which can be easily integrated into the L2 construct and enabled via a prop.

Use Case

I want to create a dashboard of data like origin latency, Lambda@Edge error rate etc. and alarm on these metrics.

Proposed Solution

An additional prop for cloudfront.Distribution:

new Distribution(this, 'Distro', {
    ...,
    publishAdditionalMetrics: true,  // default: false
});

If this is set to true a CfnMonitoringSubscription instance is created:

new CfnMonitoringSubscription(nextJsDeployment.distribution, 'MonitoringSubscription', {
    distributionId: nextJsDeployment.distribution.distributionId,
    monitoringSubscription: {
        realtimeMetricsSubscriptionConfig: {
            realtimeMetricsSubscriptionStatus: 'Enabled',
        }
    }
});

Also, we probably want to expose these metrics via distro.metricsXyz() methods (should probably throw, if publishAdditionalMetrics is set to false.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.50.0

Environment details (OS name and version, etc.)

n/a

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-cloudfrontRelated to Amazon CloudFronteffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions