访问 JSON 数组中的值

Mar*_*las 5 amazon-cloudwatch amazon-cloudwatchlogs

我按照文档中的说明了解如何访问 CloudWatch Insights 中的 JSON 值,其中建议如下

JSON arrays are flattened into a list of field names and values. For example, to specify the value of instanceId for the first item in requestParameters.instancesSet, use requestParameters.instancesSet.items.0.instanceId.
Run Code Online (Sandbox Code Playgroud)

参考 https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_AnalyzeLogData-discoverable-fields.html

我正在尝试以下操作,但没有得到任何回报。智能感知会自动填充最多processList.0但不会更多

fields processList.0.vss
| sort @timestamp desc
| limit 1
Run Code Online (Sandbox Code Playgroud)

我正在使用的 JSON 是

"processList": [
        {
            "vss": xxxxx,
            "name": "aurora",
            "tgid": xxxx,
            "vmlimit": "unlimited",
            "parentID": 1,
            "memoryUsedPc": 16.01,
            "cpuUsedPc": 0.01,
            "id": xxxxx,
            "rss": xxxxx
        },
        {
            "vss": xxxx,
            "name": "aurora",
            "tgid": xxxxxx,
            "vmlimit": "unlimited",
            "parentID": 1,
            "memoryUsedPc": 16.01,
            "cpuUsedPc": 0.06,
            "id": xxxxx,
            "rss": xxxxx
        }]
Run Code Online (Sandbox Code Playgroud)

小智 1

您尝试过以下方法吗?

fields @@timestamp, @processList.0.vss
| sort @@timestamp desc
| limit 5
Run Code Online (Sandbox Code Playgroud)

这可能是一个语法错误。如果没有,请发布一些有关整体结构的记录,其中包括@timestamp。