[英]Filter pattern for cloud watch log group using aws-sdk
I'm trying to fetch the cloud watch(log group) logs based upon a filter.我正在尝试根据过滤器获取云监视(日志组)日志。 On my
yaml
file, I've given the filter pattern as FilterPattern: "Success response"
.在我的
yaml
文件中,我将过滤器模式指定为FilterPattern: "Success response"
。 So after deploying the lambda function, it throws an error saying - Invalid Subscription filter pattern(Service:cloudWatchLogs, StatusCode: 400,...
因此,在部署 lambda function 后,它会抛出一条错误消息 -
Invalid Subscription filter pattern(Service:cloudWatchLogs, StatusCode: 400,...
The log looks like this -日志看起来像这样 -
{"info":"xxxxx", "message": "Success response","timeStamp": "2022-11-28 11:14 44:12", ......}
I want all the logs which has the word "Success response".我想要所有带有“成功响应”一词的日志。
Note: I'm using Subscription filters with AWS Lambda.注意:我在 AWS Lambda 中使用订阅过滤器。
You can use this:你可以使用这个:
FilterPattern: '{ $.message = "Success response" }'
Your logs are JSON formatted so $
will let you access the parsed version.您的日志格式为 JSON,因此
$
将允许您访问已解析的版本。
$.message
will return the message field and the filter checks if it is equal to the string you provided. $.message
将返回消息字段,过滤器检查它是否等于您提供的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.