- Newest
- Most votes
- Most comments
Can you give an example of logs you have?
To see the logs you can check out Logs Insights and create a query like
fields @timestamp, @message, @logStream, @log | filter userId like "123"
To create an alarm for these errors there are probably two solutions. Remember, that alarms are always based on metrics. That means you need to get somehow a metric for all errors by user ID.
1. Create a Custom Metric
You could create a custom metric within your code (e.g. with the EMF format) and add the user ID as a dimension. Then you can create an alarm on this metric. Since the dimension is the user ID you would need to create a metric insight query for that that this is dynamic.
2. Create Metric Filter
You could create a metric filter. This creates a new metric based on your logs. You need to define a filter based on your logs, for example:
{ $.consumerID = "specificConsumerID" && $.error = true }
This could be a bit cumbersome if you need to do this for all new users so I don't think this is really suitable.
But I think you can also just create a filter on the error $.error = true
and add the consumerID as a dimension.
I hope that helps, need to implement it myself to check if I missed something.
Hello, you can accomplish this by setting up CloudWatch Logs subscriptions targeting a Lambda function ( and in the lambda you can create ur desired alarm)
Relevant content
- asked a year ago
- What's the difference between Lambda function execution role permissions and invocation permissions?AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago