Initiate cloudwatch alarm based on the metric filter dimension

76 views Asked by At

I have setup cloudwatch metric filter like below:

MetricFilterWNEClientDiskFull:
  Type: AWS::Logs::MetricFilter
  Properties:
    LogGroupName:  ${file(resources/serverless.common.yml):logGroupWNEC}
    FilterPattern: '{ $.message = "disk out of space" }'
    MetricTransformations:
      - MetricName: WNEClientDiskOutOfSpaceCount
        MetricNamespace: ${self:custom.MetricNamespaces.websocket}
        MetricValue: "1"
        # Unit: Count
        Dimensions:
          - Key: clientId
            Value: $.clientId

And cloudwatch alarm based on this metric filter:

WNEClientErrorsDiskFull:
  Type: 'AWS::CloudWatch::Alarm'
  Properties:
    AlarmName: wnec-disk-full-alarm-${opt:stage}
    Namespace: ${self:custom.MetricNamespaces.websocket}
    MetricName: WNEClientDiskOutOfSpaceCount
    Dimensions:
      - Name: clientId
        Value: "*"
    Statistic: SampleCount
    # Unit: Count
    Period: 300
    EvaluationPeriods: 1
    Threshold: 1
    ComparisonOperator: GreaterThanOrEqualToThreshold
    AlarmActions:
      - Ref: AlarmsTopic
    TreatMissingData: notBreaching
    OKActions:
      - Ref: AlarmsTopic

I want to initiate the alarm for any client id that is captured by metric filter but it seems CloudWatch Alarm is expecting a static value. How to setup Dimensions in CloudWatch alarm for this scenario?

0

There are 0 answers