AWS Fundamentals Logo
AWS Fundamentals
L1 ConstructAWS::CloudWatch::MetricStream

CfnMetricStream

Creates or updates a metric stream. Metrics streams can automatically stream CloudWatch metrics to AWS destinations including Amazon S3 and to many third-party solutions. For more information, see [Metric streams](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Metric-Streams.html) . To create a metric stream, you must be logged on to an account that has the `iam:PassRole` permission and either the *CloudWatchFullAccess* policy or the `cloudwatch:PutMetricStream` permission. When you create or update a metric stream, you choose one of the following: - Stream metrics from all metric namespaces in the account. - Stream metrics from all metric namespaces in the account, except for the namespaces that you list in `ExcludeFilters` . - Stream metrics from only the metric namespaces that you list in `IncludeFilters` . When you create a metric stream, the stream is created in the `running` state. If you update an existing metric stream, the state does not change. If you create a metric stream in an account that has been set up as a monitoring account in CloudWatch cross-account observability, you can choose whether to include metrics from linked source accounts in the metric stream.

Import

import { CfnMetricStream } from 'aws-cdk-lib/aws-cloudwatch';

Or use the module namespace:

import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
// cloudwatch.CfnMetricStream

Properties

Configuration passed to the constructor as CfnMetricStreamProps.

firehoseArnRequired
string | IDeliveryStreamRef

The ARN of the Amazon Kinesis Firehose delivery stream to use for this metric stream. This Amazon Kinesis Firehose delivery stream must already exist and must be in the same account as the metric stream.

outputFormatRequired
string

The output format for the stream. Valid values are `json` , `opentelemetry1.0` and `opentelemetry0.7` For more information about metric stream output formats, see [Metric streams output formats](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-metric-streams-formats.html) . This parameter is required.

roleArnRequired
string | IRoleRef

The ARN of an IAM role that this metric stream will use to access Amazon Kinesis Firehose resources. This IAM role must already exist and must be in the same account as the metric stream. This IAM role must include the `firehose:PutRecord` and `firehose:PutRecordBatch` permissions.

excludeFiltersOptional
IResolvable | IResolvable | MetricStreamFilterProperty[]

If you specify this parameter, the stream sends metrics from all metric namespaces except for the namespaces that you specify here. You cannot specify both `IncludeFilters` and `ExcludeFilters` in the same metric stream. When you modify the `IncludeFilters` or `ExcludeFilters` of an existing metric stream in any way, the metric stream is effectively restarted, so after such a change you will get only the datapoints that have a timestamp after the time of the update.

includeFiltersOptional
IResolvable | IResolvable | MetricStreamFilterProperty[]

If you specify this parameter, the stream sends only the metrics from the metric namespaces that you specify here. You cannot specify both `IncludeFilters` and `ExcludeFilters` in the same metric stream. When you modify the `IncludeFilters` or `ExcludeFilters` of an existing metric stream in any way, the metric stream is effectively restarted, so after such a change you will get only the datapoints that have a timestamp after the time of the update.

includeLinkedAccountsMetricsOptional
boolean | IResolvable

If you are creating a metric stream in a monitoring account, specify `true` to include metrics from source accounts that are linked to this monitoring account, in the metric stream. The default is `false` . For more information about linking accounts, see [CloudWatch cross-account observability](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html)

nameOptional
string

If you are creating a new metric stream, this is the name for the new stream. The name must be different than the names of other metric streams in this account and Region. If you are updating a metric stream, specify the name of that stream here.

statisticsConfigurationsOptional
IResolvable | IResolvable | MetricStreamStatisticsConfigurationProperty[]

By default, a metric stream always sends the MAX, MIN, SUM, and SAMPLECOUNT statistics for each metric that is streamed. You can use this parameter to have the metric stream also send additional statistics in the stream. This array can have up to 100 members. For each entry in this array, you specify one or more metrics and the list of additional statistics to stream for those metrics. The additional statistics that you can stream depend on the stream's `OutputFormat` . If the `OutputFormat` is `json` , you can stream any additional statistic that is supported by CloudWatch , listed in [CloudWatch statistics definitions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html) . If the `OutputFormat` is OpenTelemetry, you can stream percentile statistics.

tagsOptional
CfnTag[]

An array of key-value pairs to apply to the metric stream. For more information, see [Tag](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html) .

CloudFormation Resource

This L1 construct maps directly to the following CloudFormation resource type.

Get the Amazon CloudWatch Cheat Sheet

Everything you need to know about Amazon CloudWatch on one page. HD quality, print-friendly.

Download Free Infographic