Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudwatch insights query modification

Current query :
fields  @message
| filter @message like /ABCD/
| stats count(@message)

result: @messages 1 55 now need to add more like a filter in this query like/BCDE/,/EFGH/,/IJKL/..... the expected result should be like @ABCD @BCDE @EFGH @IJKL... 55 66 77 88.

Can get like this? all the search keywords must be searched in the entire CloudWatch log.

like image 293
Kiran Kumar Avatar asked Mar 04 '23 09:03

Kiran Kumar


1 Answers

This should work for you:

fields  @message
| filter @message like /ABCD|BCDE|EFGH|IJKL/ 
| fields strcontains(@message, "ABCD") as @CONTAINS_ABCD,
         strcontains(@message, "BCDE") as @CONTAINS_BCDE,
         strcontains(@message, "EFGH") as @CONTAINS_EFGH,
         strcontains(@message, "IJKL") as @CONTAINS_IJKL
| stats sum(@CONTAINS_ABCD) as @ABCD, 
        sum(@CONTAINS_BCDE) as @BCDE, 
        sum(@CONTAINS_EFGH) as @EFGH, 
        sum(@CONTAINS_IJKL) as @IJKL
like image 180
Dejan Peretin Avatar answered Mar 10 '23 02:03

Dejan Peretin