Amazon CloudWatch

2021/03/30 - Amazon CloudWatch - 6 new api methods

Changes  SDK update for new Metric Streams feature

StartMetricStreams (new) Link ¶

Starts the streaming of metrics for one or more of your metric streams.

See also: AWS API Documentation

Request Syntax

client.start_metric_streams(
    Names=[
        'string',
    ]
)
type Names

list

param Names

[REQUIRED]

The array of the names of metric streams to start streaming.

This is an "all or nothing" operation. If you do not have permission to access all of the metric streams that you list here, then none of the streams that you list in the operation will start streaming.

  • (string) --

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

ListMetricStreams (new) Link ¶

Returns a list of metric streams in this account.

See also: AWS API Documentation

Request Syntax

client.list_metric_streams(
    NextToken='string',
    MaxResults=123
)
type NextToken

string

param NextToken

Include this value, if it was returned by the previous call, to get the next set of metric streams.

type MaxResults

integer

param MaxResults

The maximum number of results to return in one operation.

rtype

dict

returns

Response Syntax

{
    'NextToken': 'string',
    'Entries': [
        {
            'Arn': 'string',
            'CreationDate': datetime(2015, 1, 1),
            'LastUpdateDate': datetime(2015, 1, 1),
            'Name': 'string',
            'FirehoseArn': 'string',
            'State': 'string',
            'OutputFormat': 'json'|'opentelemetry0.7'
        },
    ]
}

Response Structure

  • (dict) --

    • NextToken (string) --

      The token that marks the start of the next batch of returned results. You can use this token in a subsequent operation to get the next batch of results.

    • Entries (list) --

      The array of metric stream information.

      • (dict) --

        This structure contains the configuration information about one metric stream.

        • Arn (string) --

          The ARN of the metric stream.

        • CreationDate (datetime) --

          The date that the metric stream was originally created.

        • LastUpdateDate (datetime) --

          The date that the configuration of this metric stream was most recently updated.

        • Name (string) --

          The name of the metric stream.

        • FirehoseArn (string) --

          The ARN of the Kinesis Firehose devlivery stream that is used for this metric stream.

        • State (string) --

          The current state of this stream. Valid values are running and stopped .

        • OutputFormat (string) --

          The output format of this metric stream. Valid values are json and opentelemetry0.7 .

StopMetricStreams (new) Link ¶

Stops the streaming of metrics for one or more of your metric streams.

See also: AWS API Documentation

Request Syntax

client.stop_metric_streams(
    Names=[
        'string',
    ]
)
type Names

list

param Names

[REQUIRED]

The array of the names of metric streams to stop streaming.

This is an "all or nothing" operation. If you do not have permission to access all of the metric streams that you list here, then none of the streams that you list in the operation will stop streaming.

  • (string) --

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

GetMetricStream (new) Link ¶

Returns information about the metric stream that you specify.

See also: AWS API Documentation

Request Syntax

client.get_metric_stream(
    Name='string'
)
type Name

string

param Name

[REQUIRED]

The name of the metric stream to retrieve information about.

rtype

dict

returns

Response Syntax

{
    'Arn': 'string',
    'Name': 'string',
    'IncludeFilters': [
        {
            'Namespace': 'string'
        },
    ],
    'ExcludeFilters': [
        {
            'Namespace': 'string'
        },
    ],
    'FirehoseArn': 'string',
    'RoleArn': 'string',
    'State': 'string',
    'CreationDate': datetime(2015, 1, 1),
    'LastUpdateDate': datetime(2015, 1, 1),
    'OutputFormat': 'json'|'opentelemetry0.7'
}

Response Structure

  • (dict) --

    • Arn (string) --

      The ARN of the metric stream.

    • Name (string) --

      The name of the metric stream.

    • IncludeFilters (list) --

      If this array of metric namespaces is present, then these namespaces are the only metric namespaces that are streamed by this metric stream.

      • (dict) --

        This structure contains the name of one of the metric namespaces that is listed in a filter of a metric stream.

        • Namespace (string) --

          The name of the metric namespace in the filter.

    • ExcludeFilters (list) --

      If this array of metric namespaces is present, then these namespaces are the only metric namespaces that are not streamed by this metric stream. In this case, all other metric namespaces in the account are streamed by this metric stream.

      • (dict) --

        This structure contains the name of one of the metric namespaces that is listed in a filter of a metric stream.

        • Namespace (string) --

          The name of the metric namespace in the filter.

    • FirehoseArn (string) --

      The ARN of the Amazon Kinesis Firehose delivery stream that is used by this metric stream.

    • RoleArn (string) --

      The ARN of the IAM role that is used by this metric stream.

    • State (string) --

      The state of the metric stream. The possible values are running and stopped .

    • CreationDate (datetime) --

      The date that the metric stream was created.

    • LastUpdateDate (datetime) --

      The date of the most recent update to the metric stream's configuration.

    • OutputFormat (string) --

DeleteMetricStream (new) Link ¶

Permanently deletes the metric stream that you specify.

See also: AWS API Documentation

Request Syntax

client.delete_metric_stream(
    Name='string'
)
type Name

string

param Name

[REQUIRED]

The name of the metric stream to delete.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

PutMetricStream (new) Link ¶

Creates or updates a metric stream. Metric streams can automatically stream CloudWatch metrics to AWS destinations including Amazon S3 and to many third-party solutions.

For more information, see Using 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 use PutMetricStream to create a new metric stream, the stream is created in the running state. If you use it to update an existing stream, the state of the stream is not changed.

See also: AWS API Documentation

Request Syntax

client.put_metric_stream(
    Name='string',
    IncludeFilters=[
        {
            'Namespace': 'string'
        },
    ],
    ExcludeFilters=[
        {
            'Namespace': 'string'
        },
    ],
    FirehoseArn='string',
    RoleArn='string',
    OutputFormat='json'|'opentelemetry0.7',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
type Name

string

param Name

[REQUIRED]

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.

Valid characters are A-Z, a-z, 0-9, "-" and "_".

type IncludeFilters

list

param IncludeFilters

If you specify this parameter, the stream sends only the metrics from the metric namespaces that you specify here.

You cannot include IncludeFilters and ExcludeFilters in the same operation.

  • (dict) --

    This structure contains the name of one of the metric namespaces that is listed in a filter of a metric stream.

    • Namespace (string) --

      The name of the metric namespace in the filter.

type ExcludeFilters

list

param ExcludeFilters

If you specify this parameter, the stream sends metrics from all metric namespaces except for the namespaces that you specify here.

You cannot include ExcludeFilters and IncludeFilters in the same operation.

  • (dict) --

    This structure contains the name of one of the metric namespaces that is listed in a filter of a metric stream.

    • Namespace (string) --

      The name of the metric namespace in the filter.

type FirehoseArn

string

param FirehoseArn

[REQUIRED]

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.

type RoleArn

string

param RoleArn

[REQUIRED]

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 following permissions:

  • firehose:PutRecord

  • firehose:PutRecordBatch

type OutputFormat

string

param OutputFormat

[REQUIRED]

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 .

type Tags

list

param Tags

A list of key-value pairs to associate with the metric stream. You can associate as many as 50 tags with a metric stream.

Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values.

  • (dict) --

    A key-value pair associated with a CloudWatch resource.

    • Key (string) -- [REQUIRED]

      A string that you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.

    • Value (string) -- [REQUIRED]

      The value for the specified tag key.

rtype

dict

returns

Response Syntax

{
    'Arn': 'string'
}

Response Structure

  • (dict) --

    • Arn (string) --

      The ARN of the metric stream.