Which regex parser implementation does Cloudwatch Log Insights use? Which regex parsing options are used?

0

I need to understand which regex parser implementation Cloudwatch Log Insights uses, and which parsing options it uses.

For example, I can show you a regex which I know is working here via regex101. However, when I embed the regex into a Log Insights query, it doesn't work.

For context, I am happy to share my Log Insights query is here:

parse @message '[*] [*] [*] [*] [*] [*]' as category, level, event_id, source, machine, blurb
| filter event_id = '43122'
| parse @blurb /Timestamp: (?<datetime>.+)[\r\n]+Message: (?<msg>[\s\S]*)[\r\n]+Category: (?<unparsed1>[\s\S]*)Machine: (?<instance>.*)[\r\n]+(?<unparsed2>[\s\S]+)/
| display datetime, msg

When I execute the Log Insights query above, the fields of datetime and msg are empty; but the regex101 query shows that they should pick up the information that I need.

ding
posta 7 mesi fa453 visualizzazioni
1 Risposta
0

Regex norm, as tested against regex 101 tool, should work with log insights queries. But, on your test case there's a different issue here:

The regex is not working as expected because you are using a test string

I would recommend working with JSON log event and then parse, instead of text string. OR, if you cannot change how the log message is published, you can change the regex itself by following this test string: https://regex101.com/r/ZyRmeu/1

profile pictureAWS
TECNICO DI SUPPORTO
con risposta 6 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande