【问题标题】:cloudwatch metric filter with filter pattern in CloudFormation templateCloudFormation 模板中具有过滤模式的 cloudwatch 指标过滤器
【发布时间】:2020-08-06 09:24:36
【问题描述】:

我的 Cloudformation 堆栈由于无效的 filterPattern 而失败。我正在使用以下模板代码在 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

任何帮助将不胜感激!提前致谢!

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-cloudwatch amazon-cloudwatch-metrics


    【解决方案1】:

    我找到了以下解决 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"
                        }
                    ]
                }
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-16
      相关资源
      最近更新 更多