x-alarms

Syntax reference
x-alarms:
  alarm-01:
    Properties: {}
    MacroParameters: {}
    Settings: {}
    Services: []
    Topics: []

Properties

ECS Compose-X will automatically detect whether your properties define an Alarm or a Composite Alarm.

See AWS CW Alarms definition and AWS CW Composite Alarms definition

Attention

When linking to Services and/or Topics, the OKActions, AlarmActions will be overridden accordingly.

Attention

You can only create new alarms. To use existing alarms with new services would required to modify the actions of that alarm, which would be an external change to any IaC.

MacroParameters

For x-alarms, MacroParameters is here to help define in a simpler way a composite alarm. More specifically, all you have to define is the Alarm expression

MacroParameters:
  CompositeExpression: <str>

CompositeExpression

String with a logical high level expression of the composite alarm.

Hint

In your expression, use the alarm name as defined in the compose file, not using the AlarmName property! ECS Compose-X will automatically map to the CFN Alarm being created.

Services

x-alarms:
  kafka-scaling-01:
    Properties: {}
    Services:
      - name: <str>
        access: <str>
        scaling: {} # Service scaling definition

Topics

Topics syntax
x-alarms:
  alarms-01:
    Properties: {}
    Topics:
      - TopicArn: <str>
        NotifyOn: okay
      - x-sns: <str>
        NotifyOn: all

TopicArn

A string representing the topic ARN. The topic ARN must be valid (will be validated).

x-sns

Allows you to define a SNS topic that was defined in compose-x files already. Supports new created topics and topics found via Lookup.

NotifyOn

This allows you to determine whether the messages should be published based on the alarm status.

Value

Alarm actions

all

OKActions

AlarmActions

alarm

AlarmActions

okay

OKActions

Examples

Alarm with scaling actions for service
---
# x-alarms basic use-case

x-alarms:
  alarm-01:
    Properties:
      ActionsEnabled: True
      AlarmDescription: A simple CW alarm
      ComparisonOperator: GreaterThanOrEqualToThreshold
      DatapointsToAlarm: 1
      Dimensions:
        - Name: Cluster
          Value: DEV
        - Name: Topic
          Value: sainsburys.data.price-specification.batch.v1
        - Name: ConsumerGroup
          Value: sainsburys.applications.sc-dis.price-specification.retail-price.aut-test-consumer
      EvaluationPeriods: 5
      MetricName: TotalLagForTopicAndConsumerGroup
      Namespace: lag-metrics-v4
      Period: 60
      Statistic: Sum
      Threshold: 1.0
      TreatMissingData: notBreaching


    Services:
      - name: app03
        access: NA
        Scaling:
          scaling_in_cooldown: 300
          scaling_out_cooldown: 60
          steps:
            - lower_bound: 0
              upper_bound: 1000
              count: 1
            - lower_bound: 1000
              upper_bound: 10000
              count: 3
    Topics:
      - TopicArn: arn:aws:sns:eu-west-1:012346578900:topic/sometopic
      - x-sns: topic-01


x-sns:
  Topics:
    topic-01:
      Properties: {}
Example CompositeAlarm with MacroParameters
x-alarms:
  alarm-01:
    Properties {}

  alarm-02:
    Properties: {}

  composite-alarm:
    MacroParameters:
      CompositeExpression: ALARM(alarm-01) and ALARM(alarm-02)

Hint

When the alarms is only for the service, the alarm gets created in the same stack as the service(s). When the alarm has both services and topics, the alarms are created in a separate stack.

Hint

When defining a composite alarm, the actions defined in Services or Topics are ignored.