When we create metric filters from the Management Console, we can first test filter patterns against existing log data and then create the filter by going through the following steps:
- Log in to AWS Console and go to CloudWatch.
- Click on Logs from the sidebar. This will display the log groups, as shown in the following screenshot:
- Select a log group and click on Create Metric Filter. This will take us to the Define Logs Metric Filter page. Enter the filter pattern (for example, Hello), select a log stream, and click on Test Pattern, as shown in the following screenshot:
- Click on Assign Metric. This will take us to the Create Metric Filter and Assign a Metric page. Enter filter name, metric namespace, and provide a metric name, as shown in the following screenshot:
- Click on Create Filter. If successful, we should see the following message: