Cloudwatch 见解,按 JSON 值的值查询图表?

发布于 2025-01-20 00:02:05 字数 943 浏览 4 评论 0原文

我的日志中有一个JSON对象,显示为以下内容:

"result":{
   "totalRecords":8,
   "bot":3,
   "member":5,
   "message":0,
   "reaction":0,
   "success":0,
   "error":0,
   "unknown":8
}

我正在尝试编写一个日志见解查询来绘制每个键的值。从本质上讲,我想要一个具有不同行的线图,以适应每个键的值。目前,我的查询如下:

fields result.bot, result.error, result.member, result.message, result.reaction, 
result.success, result.totalRecords, result.unknown
| stats count(result.bot), count(result.error), 
 count(result.member),count(result.message),
 count(result.reaction),count(result.success),
 count(result.totalRecords), count(result.unknown) by bin(30s)

这返回了键在日志中显示多少次的数量,但没有值。

我需要知道的是您用来获取给定键的值。我尝试在.0附加附加,例如count(result.totalrecords.0),如AWS文档中建议的,但不会返回任何值。钥匙值的查询是什么?

I've got a JSON object in my logs that shows up as the following:

"result":{
   "totalRecords":8,
   "bot":3,
   "member":5,
   "message":0,
   "reaction":0,
   "success":0,
   "error":0,
   "unknown":8
}

I'm trying to write a logs insights query to graph the values of each of those keys. Essentially I want a line chart with a different line for the value of each of the keys. Currently I have my query as the following:

fields result.bot, result.error, result.member, result.message, result.reaction, 
result.success, result.totalRecords, result.unknown
| stats count(result.bot), count(result.error), 
 count(result.member),count(result.message),
 count(result.reaction),count(result.success),
 count(result.totalRecords), count(result.unknown) by bin(30s)

This returns the count of how many times the keys show up in the logs, but not the values.

Graph

What I need to know is what you use to get the value of a given key. I tried appending a .0 for example count(result.totalRecords.0) as was suggested in the AWS docs but it doesn't return any value. What is the query for the value of a key?

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

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

发布评论

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

评论(1

顾挽 2025-01-27 00:02:05

基于文档

计算日志事件。 count()(或计数(*))计数查询返回的所有事件,而计数(fieldName)计数包括指定字段名称的所有记录。

您可以代替

stats sum(result.bot), sum(result.error) by bin (30s)

等等。这将为您提供30秒内的这些值的总和。如果您想要更大的粒度,则可以缩短时期。

Based on documentation

Counts the log events. count() (or count(*)) counts all events returned by the query, while count(fieldName) counts all records that include the specified field name.

You can write instead

stats sum(result.bot), sum(result.error) by bin (30s)

etc. This will give you sum of those values over 30s periods. You can shorten the period if you want greater granularity.

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