CloudWatchLogs / Client / test_metric_filter

test_metric_filter#

CloudWatchLogs.Client.test_metric_filter(**kwargs)#

Tests the filter pattern of a metric filter against a sample of log event messages. You can use this operation to validate the correctness of a metric filter pattern.

See also: AWS API Documentation

Request Syntax

response = client.test_metric_filter(
    filterPattern='string',
    logEventMessages=[
        'string',
    ]
)
Parameters:
  • filterPattern (string) –

    [REQUIRED]

    A symbolic description of how CloudWatch Logs should interpret the data in each log event. For example, a log event can contain timestamps, IP addresses, strings, and so on. You use the filter pattern to specify what to look for in the log event message.

  • logEventMessages (list) –

    [REQUIRED]

    The log event messages to test.

    • (string) –

Return type:

dict

Returns:

Response Syntax

{
    'matches': [
        {
            'eventNumber': 123,
            'eventMessage': 'string',
            'extractedValues': {
                'string': 'string'
            }
        },
    ]
}

Response Structure

  • (dict) –

    • matches (list) –

      The matched events.

      • (dict) –

        Represents a matched event.

        • eventNumber (integer) –

          The event number.

        • eventMessage (string) –

          The raw event data.

        • extractedValues (dict) –

          The values extracted from the event data by the filter.

          • (string) –

            • (string) –

Exceptions

  • CloudWatchLogs.Client.exceptions.InvalidParameterException

  • CloudWatchLogs.Client.exceptions.ServiceUnavailableException