问题
With this code, and using the FilterLogEvents function I am getting the logs from Cloudwatch that match these parameters:
{
"endTime": number,
"filterPattern": "string",
"interleaved": boolean,
"limit": number,
"logGroupName": "string",
"logStreamNames": [ "string" ],
"nextToken": "string",
"startTime": number
}
The code:
response = self.cloudWatchLogs.filter_log_events(**kwargs)
I defined filterPattern to be "ERROR" so that I can get all the error logs. My problem is that I get also other logs with the string : INTERRORESEAU. I set the filterPattern to ".ERROR:" but I still get the fake errors. How to tell the filterpattern to pick only and explicitly ERROR ?
回答1:
Your filter pattern should be :
kwargs['filterPattern']='".ERROR:"'
Like that you make sure you are picking the exact error word.
来源:https://stackoverflow.com/questions/41635843/filterpattern-of-filterlogevents-does-not-pick-the-string-explicitly