Visualization through CloudWatch Insights

60 views Asked by At

I am logging automation results in CloudWatch logs. The format is like this:


(XXXX-XXXX) Endpoint request body after transformations: 
{
    "executionDetails": {
        "executionId": "uniqueExecutionId",
        "userName": "<userName>",
        "sourcePackage": "<testPackage>"
}
}

Now, I want to understand the number of unique users of our framework. How do I get that data through cloudwatch insights?

I tried the following query:

fields @timestamp, @message
| filter @message like /Endpoint request body after transformations:/
| parse @message "userName" as userName
| stats count(userName) as UniqueMessageCount by userName
| sort UniqueMessageCount desc

and this too:

fields @timestamp, @message
| filter @message like /Endpoint request body after transformations:/
| parse @message "userName" as users
| stats count(users) as uniqueMessageCount by users
| sort uniqueUsers desc

But this doesn't seem to be giving the correct results. I found the following question, which seems to be similar what I am asking, but all the answers give incorrect results - Count unique values in aws cloudwatch metric .

I also need to log which user executed how many times. Can anyone help me with this?

Sharing an example of my data:

|":"John","sourcePackage":"<my package 1 >"}}| 1
|":"John","sourcePackage":"<my package 2 >"}}| 1

These 2 should be shown as :

|"John"| 2
0

There are 0 answers