Add CloudWatch Log Stream name to Metric filter dimension


Hello there, I am creating a CW Metric Filter on my Log Group. Inside my log group I have multiple log streams each prefixed with the EC2 instance ID. I want to use the instance ID as a dimension in my metric filter. Is this possible?

    Type: AWS::Logs::MetricFilter
      FilterPattern: "Connection timed out"
      LogGroupName: "/my/loggroup"
        - MetricValue: "1"
          DefaultValue: "0"
          MetricNamespace: "MyApp/VendorStatus"
          MetricName:  "Status"
          Unit: Count
            - Key: InstanceId
              Value: ???

Is it possible to populate the Dimensions.Value with the log stream name?

1 Answer

I would like to inform you that , Amazon CloudWatch Logs announces Dimension support for Metric Filters. CloudWatch Logs Metric Filters allow you to create filter patterns to search for and match terms, phrases, or values in your CloudWatch Logs log events, and turn these into metrics that you can graph in CloudWatch Metrics or use to create a CloudWatch Alarm. Now with Dimension support for Metric Filters you can create metrics from JSON or space-delimited logs with up to 3 dimensions, where a dimension is a key-value pair that is part of the identity of a metric.

Having said that, A dimension is a name/value pair that is part of the identity of a metric. Because dimensions are part of the unique identifier for a metric, whenever you add a unique name/value pair to one of your metrics, you are creating a new variation of that metric. For example, many Amazon EC2 metrics publish Instance Id as a dimension name, and the actual ‘instance ID’ as the value for that dimension[1].

Further more, The Dimensions value is from the log event and NOT log stream name. if the log events inside the log stream are JSON or space-delimited and have the instance ID then it can be possible

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions