由于无效的filterPattern,我的Cloudformation堆栈失败。我正在使用下面的模板代码在AWS中创建过滤器指标
{
"Resources": {
"404MetricFilter": {
"Type": "AWS::Logs::MetricFilter",
"Properties": {
"LogGroupName": "/aws/lambda/api-authorizer",
"FilterPattern": "['missing token:']",
"MetricTransformations": [
{
"MetricValue": "1",
"MetricNamespace": "Lambda/401s",
"MetricName": "401Count"
}
]
}
}
}
}
Lambda日志具有测试“缺少令牌:”,我需要在filterPattern中使用它。请帮助我解决此问题。 以下是lambda日志的示例:
2020-04-23T06:41:51.839Z 9486e26e-4c8a-49b8-af23-c41b902a46a4 INFO 2020-04-23T06:41:51.839 - sso:[ERROR]: source_ip="182.76.82.166" request_id="021ca9cb-5e55-4c49-98da-3d5bbd7a3236" event_description="Error occurred: missing token: ms-sso" event_severity="high" event_status="failure" event_type="read" service_name="data-lambda"
我浏览了AWS提供的文档,但无济于事:https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html
任何帮助将不胜感激!预先感谢!
答案 0 :(得分:0)
我找到了以下解决filterPattern问题的解决方案:
{
"Resources": {
"404MetricFilter": {
"Type": "AWS::Logs::MetricFilter",
"Properties": {
"LogGroupName": "/aws/lambda/mstar-fp-api-qa-us-east-1-lambda-api-authorizer",
"FilterPattern": "event_description=\"Error occurred: missing token:\"",
"MetricTransformations": [
{
"MetricValue": "1",
"MetricNamespace": "Lambda/401s",
"MetricName": "401Count"
}
]
}
}
}
}