简体   繁体   English

监控 aws lambda

[英]Monitoring on aws lambda

My python3 lambda functions process records from dynamodb.我的 python3 lambda 函数处理来自 dynamodb 的记录。 I am printing every step of my lambda execution in cloudwatch.我正在 cloudwatch 中打印我的 lambda 执行的每一步。 Now I am at a stage of deploying and monitoring my lambdas in production.现在我正处于在生产中部署和监控我的 lambda 的阶段。 Is there a way I can know which records are executed by lambda as a whole in consolidated way?有什么方法可以让我知道 lambda 作为一个整体以合并的方式执行了哪些记录?

I am also using X-ray to understand how much time and errors that my lambdas are taking.我还使用 X 射线来了解我的 lambda 表达式花费了多少时间和错误。 Besides, measuring the duration, invocation, errors.此外,测量持续时间、调用、错误。 I want a way to know how many records are executed?我想要一种方法来知道执行了多少条记录? thanks.谢谢。

You could use CloudWatchLogs for logging in the custom log group and log stream.您可以使用CloudWatchLogs记录自定义日志组和日志流。

You will be able to change in the configuration names group/stream during the deployment to different stages.在部署到不同阶段期间,您将能够更改配置名称组/流。

Check out how to do it with boto3 - Client.put_log_events查看如何使用 boto3 - Client.put_log_events

You could check my sample for NodeJS - there .您可以检查我的 NodeJS 示例 -那里 The code is much simpler and graceful for python.代码对于 python 来说更简单和优雅。

PS: Drop me a comment if you have any issue with converting. PS:如果您对转换有任何疑问,请给我留言。

While printing every line to log might help you to debug and troubleshoot your code, this is a very manual and not scaleable option.虽然将每一行打印到日志中可能会帮助您调试和排除代码故障,但这是一个非常手动且不可扩展的选项。 In addition, you would lose your mind going through endless logs.此外,您会在无休止的日志中失去理智。

In the serverless world (and specifically in AWS, where you have Lambda, DynamoDB, SQS, SNS, API Gateway, and lots of other resources), you should use the right tools that will give you visibility into your architecture, allow you to troubleshoot issues quickly, and will identify serverless specific issues (timeouts, out of memory, ..).在无服务器世界中(特别是在 AWS 中,您拥有 Lambda、DynamoDB、SQS、SNS、API 网关和许多其他资源),您应该使用正确的工具来让您了解您的架构,允许您排除故障快速解决问题,并将识别无服务器的特定问题(超时、内存不足等)。

One thing you can try out is to stream out all your logs from CloudWatch to an external service such as ELK.您可以尝试的一件事是将所有日志从 CloudWatch 流式传输到 ELK 等外部服务。 It will allow you to easily explore them.它将使您轻松探索它们。

Otherwise, I'm recommending to use a dedicated solution for serverless - there are several out there (our own Epsagon , IOpipe, Dashbird).否则,我建议为无服务器使用专用解决方案——有几个解决方案(我们自己的Epsagon 、IOpipe、Dashbird)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM