Filter Lambda Invocation error based on the consumer

0

We have a lambda that is invoked by different consumer. Is it possible to filter out invocation error based on a specific consumer? We would like to create an alarm based on this use case.

Qayyuum
질문됨 2달 전375회 조회
2개 답변
2

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.

profile picture
답변함 2달 전
0

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)

Paul
답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠