【问题标题】:Amazon Cloudwatch log filtering - JSON syntaxAmazon Cloudwatch 日志过滤 - JSON 语法
【发布时间】:2016-11-29 22:39:53
【问题描述】:

我有一个记录错误的 AWS Lambda 函数。错误记录如下:

console.error(err);

我正在尝试创建一个使用 JSON 日志过滤语法的 Cloudwatch 过滤器:

{ $.errorType = "ValidationException" }

我可以在日志中看到错误

2015-11-24T20:26:02.852Z 76800706-2d78-45ed-9068-46ccccafe6af { "errorMessage": "1 validation error detected: Value '[]' at 'xxxxxx' failed to satisfy constraint: Member must have length greater than or equal to 1", "errorType": "ValidationException", "stackTrace": [ ...etc... ] }

是否需要某种特殊设置或手动登录 CloudWatch 才能支持 JSON 过滤器语法?我在 CloudWatch 文档中找不到任何信息。

文档:

http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html

http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/FilterAndPatternSyntax.html#d0e19372

【问题讨论】:

    标签: json node.js amazon-web-services aws-lambda amazon-cloudwatch


    【解决方案1】:

    似乎当您从 Lambda 登录时,它会将所有内容都转换为字符串。可能与将请求时间和 ID 添加到每个项目有关。

    【讨论】:

      猜你喜欢
      • 2016-03-22
      • 2019-10-12
      • 1970-01-01
      • 2017-09-03
      • 2020-08-12
      • 1970-01-01
      • 2018-10-20
      • 2020-07-12
      • 1970-01-01
      相关资源
      最近更新 更多