Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alarm action definition in ec2_metric_alarm ansible module

I am trying to set up an cloud watch alarm witch ansible ec2_metric_alarm module and I do not know how to set it to send an email on alarm

The code is

- name: add alarm
  ec2_metric_alarm:
    state: present
    region: eu-west-1
    name: "LoadAverage"
    metric: "LoadAverage"
    statistic: Average
    comparison: ">"
    threshold: 3.0
    evaluation_periods: 3
    period: 60
    unit: "None"
    description: "Load Average"
    dimensions: {'Role':{{itme[0]}}, Node:{{item[1]}} }
    alarm_actions: ["action1","action2"]

What is the syntax or what do I do to express that I want it to send emails on in alarm_actions?

like image 717
Tomasz Swider Avatar asked Jul 08 '15 14:07

Tomasz Swider


People also ask

What are alarms in AWS?

An alarm invokes actions only when the alarm changes state. The exception is for alarms with Auto Scaling actions. For Auto Scaling actions, the alarm continues to invoke the action once per minute that the alarm remains in the new state. An alarm can watch a metric in the same account.

How do I update my CloudWatch alarm?

To edit an alarmOpen the CloudWatch console at https://console.aws.amazon.com/cloudwatch/ . In the navigation pane, choose Alarms, All Alarms. Choose the name of the alarm. Choose Edit.

How do I remove metrics from CloudWatch?

In the navigation pane, choose Log groups. In the contents pane, in the Metric Filter column, choose the number of metric filters for the log group. Under Metric Filters screen, select the check box to the right of the name of the filter that you want to delete. Then choose Delete.


1 Answers

The documentation is crappy for this one:
http://docs.ansible.com/ec2_metric_alarm_module.html

Here is what I would try based on boto:
http://docs.pythonboto.org/en/latest/ref/cloudwatch.html#module-boto.ec2.cloudwatch.alarm

alarm_actions (list of strs) – A list of the ARNs of the actions to take in ALARM state

The current supported ARNS are SNS topics or autoscalling policies.

In your case:
You need to create an SNS topic and subscribe your email address to that topic (also confirm the subscription) and after that put the SNS topic ARN as a string in the alarm_actions param that you pass to the ansible ec2_metric_alarm_module.

Hope this helps.

like image 162
Mircea Avatar answered Oct 21 '22 01:10

Mircea