grafanaamazon-cloudwatchamazon-cloudwatchlogsgrafana-alerts

Grafana query for cloud watch logs


i am getting the logs from the Cloud watch to Grafana dashboard.

However i am not able to make it panel or dashboard out of it.

What i tried is to go to Explore check for the Cloud watch logs and run the query "fields @messages"

which is returning the value

{
    "version": "0",
    "id": "sadfasdf-sdf-asfd-asdf-a3753e4aa9ae",
    "detail-type": "ECR",
    "source": "aws.ecr",
    "account": "12345",
    "time": "2020-23-29T02:36:48Z",
    "region": "us-east-1",
    "resources": [
        "arn:aws:ecr:us-east-1:XXXXXXXXXXX:repository/repo"
    ],
    "detail": {
        "scan-status": "COMPLETE",
        "repository-name": "my-repo",
        "finding-severity-counts": {
           "CRITICAL": 5,
           "MEDIUM": 3
         },
        "image-digest": "sha256:xxxxxxxxxxx",
        "image-tags": []
    }
}

so how to write query which can list the below details in dashboard or panel.

"finding-severity-counts": {
               "CRITICAL": 5,
               "MEDIUM": 3
             },

i tried something like

stats (detail.finding-severity-counts.CRITICAL) as severity 

but no luck so far dashboard not showing anything. also i think above once will only show CRITICAL value not medium.

Thanks in advance


Solution

  • Have you tried adding count to that? Like this:

    stats count(detail.finding-severity-counts.CRITICAL) as severity