使用Ansible创建CloudWatch Alarm指标 [英] Creating CloudWatch Alarm metrics using ansible
本文介绍了使用Ansible创建CloudWatch Alarm指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个库存文件,看起来像:
I have a inventory file which looks like :
[database]
syd01-dev-shared.ce4l5of4bl3z.ap-southeast-2.rds.amazonaws.com
我需要通过阅读清单为上述RDS端点配置3个cloudwatch指标. DBInstanceIdentifier实际上仅是syd01-dev-shared
,我如何才能实际选择这部分并将其提供给类似下面的内容?
I need to configure 3 cloudwatch metrics for the above RDS endpoint, by reading the inventory. The DBInstanceIdentifier is actually syd01-dev-shared
only, how can i actually pick this part and feed it to something like below??
- name: Create CPU utilization metric alarm
sudo: false
local_action: ec2_metric_alarm
state=present
region={{region}}
name="HOW_TO_READ_DBInstanceOdentifier_NAME_FROM_Inventory"
metric="CPUUtilization"
statistic=Average comparison=">="
threshold=80.0
unit="Percent"
period=300
evaluation_periods=1
description="It will be triggered when CPU utilization is more than 80% for 5 minutes"
dimensions="InstanceId"="{{ec2_facts.ansible_facts.ansible_ec2_instance_id}}"
alarm_actions=arn:aws:sns:us-east-1:123412341234:My_SNS_Notification
ok_actions=arn:aws:sns:us-east-1:123412341234:My_SNS_Notification
我不确定如何阅读广告资源,然后再根据自己的需求进行拆分.
I am not sure how to read the inventory and then split for what i am looking for.
推荐答案
- debug: var=groups.database[0].split('.')[0]
输出:
TASK: [debug var=groups.database[0].split('.')[0]] ****************************
ok: [127.0.0.1] => {
"var": {
"groups.database[0].split('.')[0]": "syd01-dev-shared"
}
}
这篇关于使用Ansible创建CloudWatch Alarm指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文