Create a metric filter for a log group - Amazon CloudWatch Logs

Create a metric filter for a log group

To create a metric filter for a log group, follow these steps.

To create a metric filter using the CloudWatch console

  1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. In the navigation pane, choose Log groups.

  3. Choose the name of the log group.

  4. Choose Actions, Create metric filter.

  5. For Filter pattern, enter the filter pattern to use. For more information, see Filter and Pattern Syntax.

  6. (Optional) To test your filter pattern, under Test Pattern, enter one or more log events to use to test the pattern. Each log event must be within one line, because line breaks are used to separate log events in the Log event messages box.

  7. Choose Next, and then enter a name for the filter.

  8. Under Metric details, for Metric namespace, enter a name for the CloudWatch namespace where the metric will be published. If this namespace doesn't already exist, be sure that Create new is selected.

  9. For Metric name, enter a name for the new metric.

  10. For Metric value, if your metric filter is counting occurrences of the keywords in the filter, enter 1. This increments the metric by 1 for each log event that includes one of the keywords.

    Alternatively, enter a token such as $size. This increments the metric by the value of the number in the size field for every log event that contains a size field.