Amazon Cloudwatch日志过滤-JSON语法 [英] Amazon Cloudwatch log filtering - JSON syntax
问题描述
我有一个AWS Lambda函数,该函数记录错误.错误记录如下:
I have an AWS Lambda function which is logging errors. Errors are logged as such:
console.error(err);
我正在尝试创建一个使用其JSON日志过滤语法的Cloudwatch过滤器:
I'm trying to create a Cloudwatch filter which uses their JSON log filtering syntax:
{ $.errorType = "ValidationException" }
我可以在日志中看到错误
I can see the error in the log
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...
]
}
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文档中找不到任何信息.
Is there some sort of special setup or manual logging into CloudWatch required to support the JSON filter syntax? I cannot find any info in the CloudWatch docs.
文档:
http://docs.aws. amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html
推荐答案
似乎是从Lambda登录时,它会将所有内容都转换为字符串.可能与将请求时间和ID添加到每个项目有关.
Seems like when you log from Lambda it turns everything in to a string. May have something to do with adding the Request time and ID to each item.
这篇关于Amazon Cloudwatch日志过滤-JSON语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!