4

Trying to write a cloud watch insights query to concatenate error messages for the same timestamp to be displayed as one row rather than multiple rows in the result.

So far I have tried the below query.

fields @timestamp,concat(@message) | filter @message like /(?i)(Exception|error|fail|)/ | limit 20 

This displays the results are below.

2019-09-12T12:17:09.803+10:00 12:17:09,720 |-ERROR in A 2019-09-12T12:17:09.803+10:00 12:17:09,720 |-ERROR in B 2019-09-12T12:17:09.803+10:00 12:17:09,720 |-ERROR in C 

I am expecting the below result.

2019-09-12T12:17:09.803+10:00 12:17:09,720 |- ERROR in A -ERROR in B -ERROR in C

1
  • code correction filter @message like /(?i)(Exception|ERROR|fail)/ Commented Sep 13, 2019 at 6:09

1 Answer 1

9

The concat operator is not an aggregating function, so will not do what you are looking for.

Rather, it is used for concatinating multiple values in a single row, e.g.

fields @timestamp, concat("Got message ", @message, " from stream ", @logStream) 

would give you

| 2019-09-12T12:17:09.803+10:00 12:17:09,720 | Got message bla from stream some_log_stream | 

As far as I know there is no way to aggregate strings from multiple rows into a single row.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.