6

Enclose exact phrases and terms that include non-alphanumeric characters in double quotation marks (""). https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html

Then, how should I include a double quote itself in query?

3 Answers 3

6

You could use \x22 and regex. e.g.:

%\x22500\x22%

would search for "500"

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

Comments

2

Escape the double quote with backslash: \"

2 Comments

Doesn't work: Invalid character(s) in term '\'. The escape character itself is not supported.
This did work for me. e.g. filter @message like /\"something\"/
0

We had this kind of JSON:

{"code":"INPUT_VALIDATION_FAILED","fieldErrors":[{"field":"data","code":"INVALID_FORMAT"}]} 

I could parse it when I wrapped the sting in single quotes. Simple:

fields @timestamp, @message, @logStream, @log | filter @message like " Res: 400" | parse @message '{"code":"*",' as ERRORCODE | display ERRORCODE | sort @timestamp desc | limit 100 

This read the json, and parsed the ERRORCODE (ie. the INPUT_VALIDATION_FAILED) from the json.

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.