代码之家  ›  专栏  ›  技术社区  ›  Sushan Ghimire

如何通过电子邮件发送Cloudwatch日志详细信息?

  •  5
  • Sushan Ghimire  · 技术社区  · 9 年前

    CloudTrail to send alerts

    http://docs.aws.amazon.com/awscloudtrail/latest/userguide/use-cloudformation-template-to-create-cloudwatch-alarms.html

    AWS::Logs::MetricFilter 应将值传递给 AWS::CloudWatch::Alarm 然后发送信息。我已经查看了这两个项目的文档 MetricFilter 和 Alarm Dimension 更接近我想要的,但还无法从日志中读取信息。

    我本以为这是一个常见的用例,并且会有文档。我是不是错过了一些显而易见的东西?这里有人解决了这个问题吗?

    AWS::日志::MetricFilter 块:

    "AuthorizationFailuresMetricFilter": {
        "Type": "AWS::Logs::MetricFilter",
        "Properties": {
            "LogGroupName": { "Ref" : "LogGroupName" },
            "FilterPattern": "{ ($.errorCode = \"*UnauthorizedOperation\") || ($.errorCode = \"AccessDenied*\") }",
            "MetricTransformations": [
                {
                    "MetricNamespace": "CloudTrailMetrics",
                    "MetricName": "AuthorizationFailureCount",
                    "MetricValue": "1"
                }
            ]
        }
    },
    

    块

      "AuthorizationFailuresAlarm": {
          "Type": "AWS::CloudWatch::Alarm",
          "Properties": {
              "AlarmName" : "CloudTrailAuthorizationFailures",
              "AlarmDescription" : "Alarms when an unauthorized API call is made.",
              "AlarmActions" : [{ "Ref" : "AlarmNotificationTopic" }],
              "Dimensions": [
                 {
                    "Name": "errorCode",
                    "Value": ""
                 },
                 {
                    "Name": "userIdentity",
                    "Value": ""
                 }
              ],
              "MetricName" : "AuthorizationFailureCount",
              "Namespace" : "CloudTrailMetrics",
              "ComparisonOperator" : "GreaterThanOrEqualToThreshold",
              "EvaluationPeriods" : "1",
              "Period" : "300",
              "Statistic" : "Sum",
              "Threshold" : "1"
    
          }
      },
    
    1 回复  |  直到 8 年前
        1
  •  6
  •   John Rotenstein    9 年前

    这是不可能的。

    一 亚马逊CloudWatch警报 然后,当指标超过某个阈值时可以触发。然而,生成指标的传入数据与基于阈值触发的警报之间没有直接联系。

    把它想象成一个 . 旋转栅门统计人数,但不保留通过的人的信息。同样,CloudWatch警报对事件进行计数,但没有任何关于已计数事件的信息。