解析 CloudWatch Insights 日志

问题描述 投票:0回答:1

我正在尝试解析一些cloudwatch日志来构建视觉(饼图、条形图)表示。我的日志数据是 JSON 格式,如下所示:

{
    "feature": "Feature 1",
    "container": "TestContainer",
    "user": {
        "mail": "[email protected]",
        "org": "temp_org",
        "external": true
    }
}

{
    "feature": "Feature 2",
    "container": "TestContainer1",
    "user": {
        "mail": "[email protected]",
        "org": "temp1_org",
        "external": true
    }
}

我想根据

feature
container
user
等进行过滤。例如:有多少个“功能 1”请求。

以下是我的 CloudWatch 日志见解查询:

fields @timestamp, @message, feature, container, user
| filter feature = "Feature 1"
| stats count(*) as Number_of_Request by feature

此查询给了我正确的(过滤后的)结果,但它没有生成正确的绘图。可能是因为结果只是一个数字而不是时间序列。如何将其与请求总数进行聚合,以便生成正确的绘图。

amazon-cloudwatch aws-cloudwatch-log-insights
1个回答
0
投票

无需添加过滤器。下面工作正常:

fields @timestamp, @message, feature, container, user
| stats count(*) as Number_of_Request by feature
© www.soinside.com 2019 - 2024. All rights reserved.