将 AWS Log Insights 正确转换为指标以进行可视化和监控

发布于 2025-01-10 01:47:34 字数 1274 浏览 3 评论 0原文

TL;博士;

创建指标以生成有关日志见解的可靠信息的正确方法是什么?

期望什么

当前的日志见解可以类似于以下内容

AWS Log Insights

但是,使用指标分析这些日志变得更加容易(主要是因为您可以在同一图中拥有多个数据源,甚至可以执行它们之间的数学运算)。

根据文档的解决方案

据称,可以按照 这个。然而,这种方法似乎并不完全正确(我猜是因为必须在指标图中施加时间范围),提供了不正确的信息,例如:

Dashboard

问题与解决方案

在上一张图片中,我已经创建了包含指标计数(数字 7)的仪表板,对应于每 5 分钟的事件总和。此外,我还添加了与用于创建事件的信息相对应的日志洞察预览。

但是,可以看出,日志数量为 4,但事件计数显示 7。更改指标中的时间范围会产生其他类型的问题(例如,选择非常小的时间范围(如 1 秒)将无法检索任何数据或稍小的时间范围现在都会提供另一个错误的数字:例如,当有 4 个日志时为 3)。

PS

我还尝试使用 此 lambda 函数,如 Danil Smirnov 无济于事,因为它似乎会产生相同的问题。

TL;DR;

What is the proper way to create a metric so that it generates reliable information about the log insights?

What is desired

The current Log insights can be seen similar to the following

AWS Log insights

However, it becomes easier to analyse these logs using the metrics (mostly because you can have multiple sources of data in the same plot and even perform math operations between them).

Solution according to docs

Allegedly, a log can be converted to a metric filter following a guide like this. However, this approach does not seem to work entirely right (I guess because of the time frames that have to be imposed in the metric plots), providing incorrect information, for example:

Dashboard

Issue with solution

In the previous image I've created a dashboard containing the metric count (the number 7), corresponding to the sum of events each 5 minutes. Also I've added a preview of the log insight corresponding to the information used to create the event.

However, as it can be seen, the number of logs is 4, but the event count displays 7. Changing the time frame in the metric generates other types of issues (e.g., selecting a very small time frame like 1 sec won't retrieve any data, or a slightly smaller time frame will now provide another wrong number: 3, when there are 4 logs, for example).

P.S.

I've also tried converting the log insights to metrics using this lambda function as suggested by Danil Smirnov to no avail, as it seems to generate the same issues.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文