使用boto3过滤cloudwatch日志组

问题描述 投票:0回答:1

是否有办法使用 boto3 从下面的示例日志中提取状态代码? 它们都属于一个云监控日志组。 我可以查询其中任何一个,但不能同时查询。您能帮帮我吗?

2020-04-28 16:45:11,466 - elasticsearch - INFO - GET http:/0.0.0.0:9200sampledata_search。 [状态:200请求:0.004s]

2020-04-28 16:45:11,186 - werkzeug - INFO - 0.0.0.0 - - [28Apr2020 16:45:11] "POST v1savesampledata HTTP1.1" 200 -

谢谢。

aws-lambda boto3 amazon-cloudwatch amazon-cloudwatchlogs aws-cloudwatch-log-insights
1个回答
0
投票

fields coalesce(status1, status2) as status

If you have the opportunity, consider sending JSON key

解析 @message status:(??\d{3}" (?\d{3}) 值对到CloudWatch日志。这将使您在查询时更加轻松,因为这些字段会自动为您发现和提取。

例如,给定这样的日志事件。{ "method": "POST", "status": 200 }

你的查询将是简单的。

字段状态

© www.soinside.com 2019 - 2024. All rights reserved.