A boilerplate Terraform configuration for AWS infrastructure to support CloudWatch Metric Streams for the delivery of metrics into Datadog.
This offers significantly faster delivery of CloudWatch metrics into Datadog, via a CloudWatch metric stream for batching/pushing into Datadog every 2-3 minutes vs. the traditional approach of Datadog polling CloudWatch APIs for metrics approximately every 10 minutes.
Resources created and their interplay:
- CloudWatch metric stream takes selected CloudWatch metric AWS namespaces and feeds into a connected Kinesis Firehose delivery stream.
- Kinesis Data Firehose delivery stream buffers received stream metrics and periodically pushes to a nominated HTTP target endpoint - in this instance the Datadog metrics intake API.
- An S3 bucket, which is required by the Kinesis Data Firehose delivery stream to store either: all data received, or data which failed delivery to the Datadog metrics intake API. The Terraform configuration presented here uses the latter mode of operation (delivery failures only).
See example.tfvars
for usage of these variables.
Variable | Description |
---|---|
datadog_api_key |
Datadog API key, sent along with HTTP push requests made by the Kinesis Data Firehose delivery stream. |
datadog_firehose_endpoint |
HTTPS endpoint for delivery of metrics payloads into Datadog. Will differ based on the location of your Datadog account (US/EU). |
datadog_metric_stream_namespace_list |
List of CloudWatch metric namespaces for streamed delivery. Note: Metrics which are not delivered to Datadog via the stream will continue to pulled using the classic CloudWatch API polling method. |
datadog_buffering_interval_seconds |
How often Kinesis Data Firehose metric buffer is flushed to the HTTP endpoint. Smaller values result in metrics appearing faster, at the cost of a greater number of Datadog HTTP API calls. |
- https://aws.amazon.com/blogs/aws/cloudwatch-metric-streams-send-aws-metrics-to-partners-and-to-your-apps-in-real-time/
- https://www.datadoghq.com/blog/amazon-cloudwatch-metric-streams-datadog/
- https://docs.datadoghq.com/integrations/guide/aws-cloudwatch-metric-streams-with-kinesis-data-firehose/
- https://aws.amazon.com/about-aws/whats-new/2023/12/amazon-kinesis-data-firehose-zero-buffering/
- Terraform AWS provider resources: