AWS Lambda - 错误来源?

发布于 2025-01-11 22:30:52 字数 768 浏览 0 评论 0原文

AWS Lambda 提供了一个名为“错误计数和成功率 (%)”的 CloudWatch/所有指标/仪表板。

输入图片此处描述

可从 AWS Lambda/Dashboard/Error count and successrate (%)/View in Metrics 获取此控制面板的链接。提示单击右上角错误图中的汉堡包。

问题: 我正在寻找导致错误创建的 Lambda 错误来源(可能有 1 个或数百个函数)?

为什么: 我需要抛出错误的 Lambda 函数列表(对我来说,它们通常是超时),但我们想要跟踪的这些错误可能会随着时间的推移而改变。

我能做什么: 我可以为每个 Lambda 函数创建特定的 CloudWatch 规则。这效率不高,因为可能有 100 个 +++ 函数。我也可以使用 CDLI,但这仅限于最多 20 倍的 CloudWatch Logs,即:

aws 日志启动查询 --log-group-name /aws/lambda/lambdaFunction1020 --开始时间 1646185910 --结束时间 1646358710 --query-string '字段@timestamp,@message |筛选 @message 就像“任务超时”|排序 @timestamp desc |限制20'

AWS Lambda provides a CloudWatch/All Metrics/ Dashboard called "Error count and success rate (%)".

enter image description here

The link to this Dashboard is available from AWS Lambda/Dashboard/Error count and success rate (%)/View in metrics. Tip click the hamburger in the Error graph, top right.

Question:
I am looking for the source of the Lambdas' error/s (there could be 1 or hundreds of functions) that contribute to the creation of the Errors?

Why:
I need the list of Lambda functions that are throwing errors (for me they are typically timeouts), but these errors we want to track may change over time.

What I could do:
I could create a specific CloudWatch rule for each Lambda function. This is not efficient as there maybe 100's +++ of functions. I could also use the CDLI however this is limited to a maximum of 20x CloudWatch Logs ie:

aws logs start-query --log-group-name
/aws/lambda/lambdaFunction1020 --start-time 1646185910 --end-time
1646358710 --query-string 'fields @timestamp, @message | filter
@message like "Task timed out" | sort @timestamp desc | limit 20'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷心人i 2025-01-18 22:30:52

答案就在: https://docs .aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-metrics-insights-buildquery.html

转到:Cloudwatch/All Metrics/Query 并使用以下 SQL。据我所知,返回结果的数量没有限制。我发现的唯一问题是时间范围最多限制为三 (3) 小时。

SELECT SUM(Errors)
FROM SCHEMA("AWS/Lambda", FunctionName)
GROUP BY FunctionName
ORDER BY SUM() DESC
LIMIT 10

对于许多 AWS 服务,“添加查询”下还有许多预构建的查询...

The answer is in: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-metrics-insights-buildquery.html

Go to: Cloudwatch/All Metrics/Query and use the following SQL. From what I can see there are no LIMITS on the number of results returned. The only issue I have found is the time frame is limited to a maximum of three (3) hours.

SELECT SUM(Errors)
FROM SCHEMA("AWS/Lambda", FunctionName)
GROUP BY FunctionName
ORDER BY SUM() DESC
LIMIT 10

There is also a number of pre-built queries under "Add query" for many AWS services...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文