I’m trying to create 1 single alert (rather than 3 different ones) to alert if a particular log message is not found in my lambda log. I plan to run this via a workflow daily to alert if the message is not found for that day.
What I so far is below which will show me the log group and the count for when the message is found but what I am seeing is that if the message is not found then there is no record shown for that log group, see sample below. My query has 3 log groups but my result shows only 2 log groups because ‘Successfully updated number of accounts:’ was not found in log-group-3. Any thoughts on how I can get around this?
fetch logs,from:-24h
| filter (matchesPhrase(content, "Successfully deleted profile count:") AND (aws.log_group == "/aws/lambda/log-group-1" OR aws.log_group == "/aws/lambda/log-group-2")) OR matchesPhrase(content, "Successfully updated number of accounts:") AND aws.log_group == "/aws/lambda/log-group-3"
| summarize count = count(), by:{aws.log_group}
| fieldsAdd non_zero_count = if(count != 0, 0)
Sample output
