Ula*_*ach 12 json amazon-web-services amazon-cloudwatch aws-cloudwatch-log-insights
有什么方法可以获取在云监视日志洞察解析的 JSON 对象中找到的数组的长度?
例如,当发送以下结构的 JSON 对象以记录洞察时:
{
names: ['john', 'doe', 'joe', 'schmoe']
}
Run Code Online (Sandbox Code Playgroud)
它被解析为以下字段:
names.0: john
names.1: doe
names.2: joe
names.3: schmoe
Run Code Online (Sandbox Code Playgroud)
并且可以通过
fields @timestamp, names.0, names.1, ...
Run Code Online (Sandbox Code Playgroud)
在这个例子中,有没有办法得到一个field
被调用的number_of_names
?
| parse get_length(names) as number_of_names
小智 2
对于已知最大长度的较小数组,这是一个丑陋的解决方法:
fields @timestamp, ispresent(names.0) + ispresent(names.1) + ispresent(names.2) + ... + ispresent(names.10) as names_length
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
963 次 |
最近记录: |