1
- name: Create Alarm
ec2_metric_alarm:
state: present
region: us-west-2
name: "Low_On_CPU"
metric: "CPUUtilization"
namespace: "AWS/EC2"
statistic: Average
comparison: ">="
threshold: 75.0
period: 300
evaluation_periods: 1
unit: "Percent"
description: "The alarm will send notification message when CPU is over 75 percent"
alarm_actions: "{{ alarm_action }}"
ok_actions: "{{ ok_action }}"
对于地区:我想为us-west-2应用云端警报,但是出现错误。其中说:Ansible ec2_metric_alarm区域问题
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "BotoServerError: 400 Bad Request\nhttp://monitoring.amazonaws.com/doc/2010-08-01/\">\n \n Sender\n
ValidationError
\n Invalid region us-east-1 specified. Only us-west-2 is supported.\n \n fca09709-ad15-11e6-89f8-c1737af27609\n\n"}
当我试图跟我们东-1相同,它的工作,但与其他地区除美国东部-1不起作用。我对我们也一样 - 东2,美西1,美西2,但没有运气。有关如何解决此问题的任何建议?
我对Ansible不熟悉,但是您发送请求的端点是什么?要为us-west-2添加一个指标,您可能必须将API请求发送到us-west-2。这通常是在与AWS连接的软件中配置的。 –
ansible拥有自己的模块,使用它可以进行API调用。它使用boto.ec2.cloudwatch创建警报。 – Ketan
对我来说很好。代码没有问题。请参阅实际的模块代码(https://github.com/ansible/ansible-modules-core/blob/devel/cloud/amazon/ec2_metric_alarm.py#L272-L278),它很简单且有效。因此,如果您遇到问题,请将错误报告提交至https://github.com/ansible/ansible-modules-core。 – BMW