简体   繁体   English

使用 aws-sdk 的云监视日志组的过滤模式

[英]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.

相关问题 如何在 NextJS 中设置 AWS-SDK 凭证 - How to setup AWS-SDK credentials in NextJS 使用玩笑模拟 aws-sdk S3#putObject 实例方法 - Mocking aws-sdk S3#putObject instance method using jest SQS 在 AWS lambda 使用@aws-sdk node.js 发送消息错误 - SQS send message error using @aws-sdk node js at AWS lambda 如何在 nodejs 中使用 `aws-sdk` 读取 cloudwatch 日志 - How can I read cloudwatch logs using `aws-sdk`in nodejs S3 为使用 aws-sdk v3 预签名的 PutObject 命令 url 提供 SignatureDoesNotMatch 错误 - S3 gives SignatureDoesNotMatch error for PutObject command pre-signed url using aws-sdk v3 DynamoDB 表种子适用于 cli 但不适用于 AWS-SDK - DynamoDB table seed works in cli but not AWS-SDK 如何将 AWS-SDK DynamoDB 指向本地无服务器 DynamoDB - How to point AWS-SDK DynamoDB to a serverless DynamoDB local 使用 aws sdk 命令行在自动缩放中形成云 - Cloud Formation in auto scaling using aws sdk command line 构建基本 Web 应用程序教程中的 AWS Lambda“找不到模块 aws-sdk” - AWS Lambda "cannot find module aws-sdk" in Build a Basic Web Application tutorial 如何在 `Node aws-sdk` sendRawEmail 函数中发送 PDF 附件? - How can send PDF attachment in `Node aws-sdk` sendRawEmail function?
 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM