AWS::CloudWatch::MetricStream - AWS CloudFormation

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.

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, ... ], "Name" : String, "OutputFormat" : String, "RoleArn" : String, "Tags" : [ Tag, ... ] } }

YAML

Type: AWS::CloudWatch::MetricStream Properties: ExcludeFilters: - MetricStreamFilter FirehoseArn: String IncludeFilters: - MetricStreamFilter Name: String OutputFormat: String RoleArn: String 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 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.

Required: No

Type: List of MetricStreamFilter

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: Yes

Type: String

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 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.

Required: No

Type: List of MetricStreamFilter

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

Update requires: Replacement

OutputFormat

The output format for the stream. Valid values are json and opentelemetry0.7 For more information about metric stream output formats, see Metric streams output formats.

This parameter is required.

Required: Yes

Type: String

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 and firehose:PutRecordBatch permissions.

Required: Yes

Type: String

Update requires: No interruption

Tags

An array of key-value pairs to apply to the metric stream.

For more information, see Tag.

Required: No

Type: List of Tag

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 or stopped.

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" } }