[英]How can I get more specific CloudWatch alerts when an AWS Lambda function fails?
I have a variety of functions, all in Node.js, in AWS Lambda. 我在AWS Lambda的Node.js中都有各种功能。 They're triggered by certain events like S3 triggers, API Gateway methods, or sometimes just called manually. 它们是由某些事件触发的,例如S3触发器,API网关方法或有时只是手动调用。 I create them by pasting code in the console or uploading a zip file I've built locally. 我通过在控制台中粘贴代码或上传我在本地构建的zip文件来创建它们。
On rare occasion, a function will fail. 在极少数情况下,功能会失败。 To detect failures, I've set up a CloudWatch alarm that looks like this: 为了检测故障,我设置了一个CloudWatch警报,如下所示:
This works, to an extent: when a function anywhere in my account fails, I get an email. 这在一定程度上有效:当我帐户中任何地方的某个功能失败时,我都会收到一封电子邮件。 The problem is the email just states that the alarm got tripped. 问题是电子邮件仅指出警报已触发。 It doesn't state what Lambda function actually failed so I have to dig through Lambda to find which function actually caused the alarm. 它没有说明什么 Lambda函数实际上失败了,所以我必须仔细研究Lambda才能找到哪个函数真正引起了警报。
I've considered the following: 我考虑过以下几点:
Any ideas on how to achieve this? 关于如何实现这一目标的任何想法?
We handle it internally. 我们在内部处理它。 When there is a problem, the Lambda attempts to handle it, and sends an alert. 出现问题时,Lambda尝试处理它,并发送警报。 The CloudWatch metric is only for truly unhandled exceptions. CloudWatch指标仅适用于真正未处理的异常。 Remember Lambda automatically retries if a function has an error, which can be undesirable for certain situations. 请记住,如果函数有错误,Lambda会自动重试,这在某些情况下是不希望的。 So it may be preferable to handle any exceptions internal to the Lambda function. 因此,最好处理Lambda函数内部的任何异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.