AWS CloudWatch Metrics

Overview

This topic explains how to stream AWS CloudWatch metrics from your AWS account to LaunchDarkly’s observability features. This integration allows you to monitor your AWS infrastructure alongside your feature flag data for unified observability.

The integration uses AWS CloudWatch Metric Streams to send metrics in real-time using the OpenTelemetry format. Data is delivered using Amazon Kinesis Data Firehose to LaunchDarkly’s OpenTelemetry Protocol (OTLP) endpoint.

Prerequisites

To use the AWS CloudWatch Metrics integration, you require:

  • A LaunchDarkly client-side ID for your target environment
  • AWS account with permissions to create:
    • CloudWatch Metric Streams
    • Kinesis Data Firehose delivery streams
    • S3 buckets
    • IAM roles and policies
  • AWS CLI installed and configured (optional, for command-line deployment)

To find and copy your LaunchDarkly client-side ID, follow the instructions under View or copy keys and credentials.

Deploy the CloudFormation template

You can deploy the AWS CloudWatch Metrics integration using the AWS CloudFormation console or the AWS CLI.

Deploy using the AWS Console

To deploy using the AWS Console:

  1. Copy the CloudFormation template below and save it as a file named metric-stream.yaml.
  2. Open the AWS CloudFormation console.
  3. Click Create stack and select With new resources (standard).
  4. Select Upload a template file, click Choose file, and select the metric-stream.yaml file you saved.
  5. Click Next.
  6. Enter a Stack name, such as launchdarkly-metrics-stream.
  7. Enter your the client-side ID from your LaunchDarkly environment into LaunchDarklyClientSideID.
  8. Click Next through the remaining steps.
  9. On the final page, acknowledge that CloudFormation will create IAM resources by checking the checkbox.
  10. Click Submit.

The stack takes 3-5 minutes to create. After creation completes, metrics begin flowing to LaunchDarkly.

Deploy using the AWS CLI

To deploy using the AWS CLI:

  1. Download the CloudFormation template:
CloudFormation template
1AWSTemplateFormatVersion: '2010-09-09'
2Description: 'CloudFormation template for LaunchDarkly observability metrics integration'
3
4Parameters:
5 LaunchDarklyClientSideID:
6 Type: String
7 Description: Your LaunchDarkly environment client-side ID
8
9 DestinationEndpoint:
10 Type: String
11 Description: OpenTelemetry endpoint URL for metrics
12 Default: https://otlpv1.firehose.observability.app.launchdarkly.com
13
14Resources:
15 MetricStreamRole:
16 Type: AWS::IAM::Role
17 Properties:
18 AssumeRolePolicyDocument:
19 Version: '2012-10-17'
20 Statement:
21 - Effect: Allow
22 Principal:
23 Service: streams.metrics.cloudwatch.amazonaws.com
24 Action: sts:AssumeRole
25 Policies:
26 - PolicyName: MetricStreamPolicy
27 PolicyDocument:
28 Version: '2012-10-17'
29 Statement:
30 - Effect: Allow
31 Action:
32 - firehose:PutRecord
33 - firehose:PutRecordBatch
34 Resource: !GetAtt DeliveryStream.Arn
35
36 BackupBucket:
37 Type: AWS::S3::Bucket
38 DeletionPolicy: Delete
39 UpdateReplacePolicy: Delete
40 Properties:
41 LifecycleConfiguration:
42 Rules:
43 - Id: DeleteOldBackups
44 Status: Enabled
45 ExpirationInDays: 14
46
47 FirehoseRole:
48 Type: AWS::IAM::Role
49 Properties:
50 AssumeRolePolicyDocument:
51 Version: '2012-10-17'
52 Statement:
53 - Effect: Allow
54 Principal:
55 Service: firehose.amazonaws.com
56 Action: sts:AssumeRole
57 Policies:
58 - PolicyName: FirehosePolicy
59 PolicyDocument:
60 Version: '2012-10-17'
61 Statement:
62 - Effect: Allow
63 Action:
64 - logs:CreateLogStream
65 - logs:PutLogEvents
66 - logs:CreateLogGroup
67 Resource: !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/kinesisfirehose/${AWS::StackName}:*
68 - Effect: Allow
69 Action:
70 - s3:PutObject
71 - s3:GetObject
72 Resource:
73 - !Sub ${BackupBucket.Arn}/*
74
75 DeliveryStream:
76 Type: AWS::KinesisFirehose::DeliveryStream
77 Properties:
78 DeliveryStreamType: DirectPut
79 HttpEndpointDestinationConfiguration:
80 EndpointConfiguration:
81 Url: !Ref DestinationEndpoint
82 RequestConfiguration:
83 ContentEncoding: GZIP
84 CommonAttributes:
85 - AttributeName: x-launchdarkly-project
86 AttributeValue: !Ref LaunchDarklyClientSideID
87 BufferingHints:
88 IntervalInSeconds: 60
89 SizeInMBs: 1
90 RoleARN: !GetAtt FirehoseRole.Arn
91 S3BackupMode: FailedDataOnly
92 S3Configuration:
93 BucketARN: !GetAtt BackupBucket.Arn
94 BufferingHints:
95 IntervalInSeconds: 300
96 SizeInMBs: 5
97 CompressionFormat: GZIP
98 RoleARN: !GetAtt FirehoseRole.Arn
99 Prefix: failed-metrics/
100
101 MetricStream:
102 Type: AWS::CloudWatch::MetricStream
103 Properties:
104 FirehoseArn: !GetAtt DeliveryStream.Arn
105 OutputFormat: opentelemetry1.0
106 RoleArn: !GetAtt MetricStreamRole.Arn
107
108Outputs:
109 MetricStreamArn:
110 Description: ARN of the created metric stream
111 Value: !GetAtt MetricStream.Arn
112
113 FirehoseArn:
114 Description: ARN of the created Kinesis Firehose
115 Value: !GetAtt DeliveryStream.Arn
116
117 BackupBucketName:
118 Description: Name of the S3 bucket for failed delivery backups
119 Value: !Ref BackupBucket
  1. Create the CloudFormation stack:
Shell
$aws cloudformation create-stack \
> --stack-name launchdarkly-metrics-stream \
> --template-body file://metric-stream.yaml \
> --parameters \
> ParameterKey=LaunchDarklyClientSideID,ParameterValue=YOUR_CLIENT_SIDE_ID \
> --capabilities CAPABILITY_IAM

Replace YOUR_CLIENT_SIDE_ID with your LaunchDarkly environment’s client-side ID.

  1. Monitor the stack creation:
Shell
$aws cloudformation describe-stacks --stack-name launchdarkly-metrics-stream

What the template creates

The CloudFormation template creates the following AWS resources:

  • CloudWatch Metric Stream: Captures all CloudWatch metrics from all AWS services in real-time
  • Kinesis Data Firehose Delivery Stream: Buffers and delivers metrics to the LaunchDarkly OTLP endpoint
  • S3 Backup Bucket: Stores failed metric deliveries for troubleshooting (14-day retention)
  • IAM Roles: Least-privilege roles for the metric stream and Firehose delivery stream

All metrics from all AWS namespaces such as EC2, Lambda, RDS, DynamoDB, and ECS are streamed automatically, providing comprehensive visibility into your AWS infrastructure.

View metrics in LaunchDarkly Observability

After deployment, metrics appear in the LaunchDarkly observability dashboard within 1-2 minutes.

To view your metrics:

  1. Navigate to Observability in LaunchDarkly.
  2. Select the environment you configured.
  3. Navigate to the Metrics tab.
  4. Use the metric explorer to query and visualize your AWS CloudWatch metrics.

Metrics are tagged with their AWS namespace, region, and resource identifiers for easy filtering.

Filter metrics by namespace (optional)

By default, the integration sends all AWS CloudWatch metrics from all services, providing complete observability coverage. If you need to reduce cost and data volume for specific use cases, you can optionally filter to specific AWS service namespaces.

To filter metrics to specific namespaces:

  1. Download and open the CloudFormation template in a text editor.
  2. Locate the MetricStream resource.
  3. Add an IncludeFilters section, similar to:
CloudFormation YAML
1MetricStream:
2 Type: AWS::CloudWatch::MetricStream
3 Properties:
4 FirehoseArn: !GetAtt DeliveryStream.Arn
5 IncludeFilters:
6 - Namespace: AWS/EC2
7 - Namespace: AWS/Lambda
8 - Namespace: AWS/RDS
9 OutputFormat: opentelemetry1.0
10 RoleArn: !GetAtt MetricStreamRole.Arn
  1. Save the template and deploy or update the stack.

For a complete list of AWS service namespaces, read AWS services that publish CloudWatch metrics in the AWS documentation.