How to filter CloudWatch Log Insights with ispresent() function

Gustavo Lopes picture Gustavo Lopes · May 8, 2019 · Viewed 11.3k times · Source

I'm trying to perform a really simple query on the not so new AWS Cloudwatch Log Insights

I'm following their documentation to filter my logs using ispresent function.

The query is the following:

fields @timestamp, status
| filter ispresent(status) != 0

But this give me an error (the super unhelpful We are having trouble understanding the query)

How can I filter my logs by showing only the logs with the status field?

Answer

Gustavo Lopes picture Gustavo Lopes · May 9, 2019

After a while, I figured out how to do that, in a hackish way.

fields @timestamp, status, ispresent(status) as exist
| filter exist != 0

Not the best way (and it goes against their documentation), but works.