AWS CloudWatch 选择第一个现有字段
我在 AWS CloudWatch 中有两种消息,并且想要选择第一个包含一些文本的字段。例如,
消息 1:
"message": {
"message": "I am the first priority"
}
消息 2:
"message": {
"err": {
"message": "I am second priority"
}
}
我希望将这些消息放在 CloudWatch 表的单列中,具体取决于存在哪一个。有什么办法可以做到这一点吗?像这样的东西(这显然不起作用):
fields @timestamp, ispresent(message.message) ? message.message : message.err.message
I have two kinds of messages in the AWS CloudWatch and would like to select the first field that has some text in it. For example
Mesasge 1:
"message": {
"message": "I am the first priority"
}
Message 2:
"message": {
"err": {
"message": "I am second priority"
}
}
I would like to have these in a single column of the CloudWatch table depending which one is present. Is there any way to do this? Something like this (which obviously doesn't work):
fields @timestamp, ispresent(message.message) ? message.message : message.err.message
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然合并功能正是我所需要的。它选择了第一个不为空的值:
更多信息位于 CloudWatch Logs Insights查询语法
Apparently coalesce function is what I needed. It selected the first value that is not null:
More info at CloudWatch Logs Insights query syntax