AWS::CloudWatch::MetricStream
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.
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.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::CloudWatch::MetricStream", "Properties" : { "ExcludeFilters" :
[ MetricStreamFilter, ... ]
, "FirehoseArn" :String
, "IncludeFilters" :[ MetricStreamFilter, ... ]
, "IncludeLinkedAccountsMetrics" :Boolean
, "Name" :String
, "OutputFormat" :String
, "RoleArn" :String
, "StatisticsConfigurations" :[ MetricStreamStatisticsConfiguration, ... ]
, "Tags" :[ Tag, ... ]
} }
YAML
Type: AWS::CloudWatch::MetricStream Properties: ExcludeFilters:
- MetricStreamFilter
FirehoseArn:String
IncludeFilters:- MetricStreamFilter
IncludeLinkedAccountsMetrics:Boolean
Name:String
OutputFormat:String
RoleArn:String
StatisticsConfigurations:- MetricStreamStatisticsConfiguration
Tags:- Tag
Properties
ExcludeFilters
-
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
andExcludeFilters
in the same metric stream.When you modify the
IncludeFilters
orExcludeFilters
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.Required: No
Type: Array of MetricStreamFilter
Maximum:
1000
Update requires: No interruption
FirehoseArn
-
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.
Required: No
Type: String
Minimum:
20
Maximum:
2048
Update requires: No interruption
IncludeFilters
-
If you specify this parameter, the stream sends only the metrics from the metric namespaces that you specify here. You cannot specify both
IncludeFilters
andExcludeFilters
in the same metric stream.When you modify the
IncludeFilters
orExcludeFilters
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.Required: No
Type: Array of MetricStreamFilter
Maximum:
1000
Update requires: No interruption
IncludeLinkedAccountsMetrics
-
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 isfalse
.For more information about linking accounts, see CloudWatch cross-account observability
Required: No
Type: Boolean
Update requires: No interruption
Name
-
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.
Required: No
Type: String
Minimum:
1
Maximum:
255
Update requires: Replacement
OutputFormat
-
The output format for the stream. Valid values are
json
,opentelemetry1.0
andopentelemetry0.7
For more information about metric stream output formats, see Metric streams output formats.This parameter is required.
Required: No
Type: String
Minimum:
1
Maximum:
255
Update requires: No interruption
RoleArn
-
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
andfirehose:PutRecordBatch
permissions.Required: No
Type: String
Minimum:
20
Maximum:
2048
Update requires: No interruption
StatisticsConfigurations
-
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 theOutputFormat
isjson
, you can stream any additional statistic that is supported by CloudWatch, listed in CloudWatch statistics definitions. If theOutputFormat
is OpenTelemetry, you can stream percentile statistics.Required: No
Type: Array of MetricStreamStatisticsConfiguration
Maximum:
100
Update requires: No interruption
-
An array of key-value pairs to apply to the metric stream.
For more information, see Tag.
Required: No
Type: Array of Tag
Maximum:
50
Update requires: No interruption
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref
function, Ref
returns the name of the metric stream.
For more information about using the Ref
function, see Ref
.
Fn::GetAtt
The Fn::GetAtt
intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt
intrinsic function, see Fn::GetAtt
.
Arn
-
The ARN of the metric stream.
CreationDate
-
The date that the metric stream was originally created.
LastUpdateDate
-
The date that the metric stream was most recently updated.
State
-
The state of the metric stream, either
running
orstopped
.
Examples
Metric stream example
The following example creates a metric stream that streams only the metrics in the
AWS/ELB
and AWS/EC2
namespaces.
YAML
Resources: MyMetricStream: Type: 'AWS::CloudWatch::MetricStream' Properties: OutputFormat: 'json' FirehoseArn: 'arn:aws:firehose:us-east-1:123456789012:deliverystream/MyDeliveryStream' RoleArn: 'arn:aws:iam::123456789012:role/service-role/MyRole' IncludeFilters: - Namespace: AWS/ELB - Namespace: AWS/EC2
JSON
{ "Type" : "AWS::CloudWatch::MetricStream", "Properties" : { "FirehoseArn" : "arn:aws:firehose:us-east-1:123456789012:deliverystream/MyDeliveryStream", "IncludeFilters" : [ { "Namespace": "AWS/ELB" }, { "Namespace": "AWS/EC2" } ], "Name" : "MyMetricStream", "OutputFormat" : "json", "RoleArn" : "arn:aws:iam::123456789012:role/service-role/MyRole" } }