2

Is it possible to display n messages prior to a message that matches regex using aws cloud watch logs insights. I have to put a filter across multiple log events. Example log message sequence:

<time> INFO Fetching data for apple.
<time> INFO Fetching data for mango.
<time> INFO Fetching data for orange.
<time> ERROR error message. 
<time> INFO Fetching data for banana.
<time> ERROR error message. 
<time> INFO Fetching data for jackfruit.
<time> INFO Fetching data for figs.

1 Answers1

5

I don't believe this is possible.

One option is to include @logStream in the select portion of your query, which will allow you to click the logstream link to go directly to the log item, and scroll up to see the prior logs.

Not ideal for your situation, but might speed up your debugging.

maafk
  • 6,176
  • 5
  • 35
  • 58
  • When using this method, include @timestamp and @log as well. That is, `fields @timestamp, @log, @logStream`. The link uses all 3 fields - @timestamp for the start time and @log when querying multiple log groups. – gangreen Jun 08 '20 at 08:02
  • @logStream is definitely helpful. Thanks for the tip! – Michael G Aug 09 '22 at 15:15