简体   繁体   English

适用于 Lambda 的 AWS CLoudWatch 日志触发器

[英]AWS CLoudWatch Log Trigger for Lambda

I have a problem in AWS regarding CloudWatch Log Triggers.我在 AWS 中遇到了有关 CloudWatch 日志触发器的问题。

I have two Lambda functions.我有两个 Lambda 函数。 One (business-lambda) gets triggered when I upload a file to a S3 bucket.当我将文件上传到 S3 存储桶时,会触发一个 (business-lambda)。 The other Lambda function (log-lambda) is triggered whenever business-lambda encounters an invalid file which results in creating an ERROR-log entry.每当 business-lambda 遇到导致创建 ERROR-log 条目的无效文件时,就会触发另一个 Lambda 函数 (log-lambda)。 I implemented this with a CloudWatch Log Trigger with filter "?ERROR" and having the log-lambda being subscribed to the log-group of the business-lambda.我使用带有过滤器“?ERROR”的 CloudWatch Log Trigger 实现了这一点,并将 log-lambda 订阅到 business-lambda 的日志组。

Everything works fine as long as I upload one file at a time or at a maximum of ~3 files at a time.只要我一次上传一个文件或一次最多上传约 3 个文件,一切都可以正常工作。

But when I upload eg 10 invalid files at a time the log-lambda doesn't get triggered for all of the files.但是,当我一次上传例如 10 个无效文件时,不会为所有文件触发 log-lambda。 Instead it only gets triggered for 4-5 of them.相反,它只会被其中的 4-5 个触发。

Is there some kind of "Cloudwatch-log-trigger/second" limit?是否有某种“Cloudwatch-log-trigger/second”限制?

I found a solution - luk2302 made the correct suggestion in their comment.我找到了一个解决方案 - luk2302 在他们的评论中提出了正确的建议。

In the log-lambda code I only process the first entry from an incoming log-event.在 log-lambda 代码中,我只处理传入日志事件中的第一个条目。 But the log-lambda gets triggered once for multiple error-log entries from the business-lambda.但是 log-lambda 会为来自 business-lambda 的多个错误日志条目触发一次。 I did not take this into account in the log-lambda code.我在 log-lambda 代码中没有考虑到这一点。

Thanks to everybody for their time!感谢大家的时间!

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

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