1
votes

I am working with data that comes in similar format to this in insights. Sometimes the value of J may be missing and I want to set the value as the value of B if this is the case. Is there any way to do conditional logic similar to this on data in CloudWatch Insights? I have explored ispresent() but cannot figure out how to do the conditional logic.

Example:

B J
1 3
2 4
2

for the last I would like to set the data equal in J to 2 when I run the query.

1

1 Answers

1
votes

You may be able to use coalesce(J, B) which won't set the J to 2 but can be assigned to a new field (e.g. fields coalesce(J, B) as newB that can be used for display or additional logic. coalesce takes 2+ arguments and returns the first value that isn't blank.

https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html (search for coalesce)