ℹ️ Information: CloudWatch Metric Filters allow you to extract and transform log data into numerical CloudWatch metrics that you can graph or set alarms on.
Return to the main screen of Amazon CloudWatch
/ec2 in the filter box
In the /ec2/linux/var/log/messages log group interface

In the Define Pattern section, configure the following:


PythonAppErrors
In the Metric details section, configure the following:
ec2-logs/var/log/messages - ERROR


Navigate to Metrics > All metrics in the CloudWatch console
/var/log/messages and ERROR

💡 Pro Tip: You can create multiple metric filters for different error patterns or log events to gain comprehensive visibility into your application’s behavior.
🔒 Security Note: Ensure that your metric filters don’t extract sensitive information that might be present in your logs.
Now we have a metric that captures ERROR logs from the application. In the next step, we will set up a CloudWatch Alarm for this metric to receive notifications when errors occur.