grofers.rds-alarms
RDS 警报
在 Amazon CloudWatch 上为 RDS 实例创建警告和严重警报。更多详细信息,请查看 博客文章。
:boom: 在 Grofers 经受考验
要求
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt19471460522000",
"Effect": "Allow",
"Action": [
"cloudwatch:DeleteAlarms",
"cloudwatch:DescribeAlarms",
"cloudwatch:PutMetricAlarm"
],
"Resource": [
"*"
]
},
{
"Sid": "Stmt1947940274000",
"Effect": "Allow",
"Action": [
"rds:DescribeDBInstances"
],
"Resource": [
"*"
]
}
]
}
安装
要安装,只需运行
$ ansible-galaxy install grofers.rds-alarms
角色变量
rds_alarms_region
- AWS 区域(必需)rds_alarms_common_action_list
- AWS SNS 中主题的 ARN 列表rds_alarms_period
- 指标评估间隔时间(以秒为单位)rds_alarms_evaluation_periods
- 在最终计算之前评估指标的次数rds_alarms_common_action_list
- 始终包括此报警动作rds_alarms_warning_threshold
- 警告阈值(默认 - 75%)rds_alarms_critical_threshold
- 严重警告阈值(默认 - 90%)rds_alarms_warning_cpu_credits_threshold
- CPU 额度警告阈值(默认 - 30)rds_alarms_critical_cpu_credits_threshold
- CPU 额度严重警告阈值(默认 - 15)rds_alarms_db_instances
- 格式如下的字典:
rds_alarms_db_instances:
<rds-instance-identifier>:
warning_db_connections_threshold: 100
critical_db_connections_threshold: 200
warning_burst_balance_threshold: 100
critical_burst_balance_threshold: 200
alarm_action_list: ["arn:aws:sns:us-east-1:9783248248:MYALARM"]
critical_threshold: 90 # 可选
warning_threshold: 75 # 可选
credit_warning_threshold: 30 # 可选
credit_critical_threshold: 15 # 可选
replica_lag_threshold: 1800 # 仅限于副本,单位为秒
约定
在 Amazon CloudWatch 中创建的报警名称格式为:
rds-<实例名称>-<指标名称>-<警报类型>
。
例如,针对标识符为 my-rds-instance
的实例的 CPU
的 warning
警报将被创建为 rds-my-rds-instance-cpu-warning
。
示例剧本
此剧本将为 my-rds-instance-identifier
创建默认阈值的警报。而针对 my-replica-rds-instance-identifier
创建的警报将使用 80% 的警告阈值,并且严重阈值将为默认值(90%)。如果实例是副本,则还会为副本延迟创建警报。对于每个 t2 实例,还会为剩余的 CPU 额度创建警报。
- hosts: localhost
connection: local
vars:
rds_alarms_common_action_list:
- "arn:aws:sns:us-east-1:9783248248:ALARMS"
rds_alarms_period: 60
rds_alarms_evaluation_periods: 2
rds_alarms_region: us-east-1
rds_alarms_warning_threshold: 70
rds_alarms_critical_threshold: 90
rds_alarms_warning_cpu_credits_threshold: 60
rds_alarms_critical_cpu_credits_threshold: 30
rds_alarms_db_instances:
my-rds-instance-identifier: # 这将使用默认值
warning_db_connections_threshold: 100
critical_db_connections_threshold: 200
alarm_action_list: ["arn:aws:sns:us-east-1:9783248248:MYALARM"]
my-replica-rds-instance-identifier:
warning_threshold: 80
warning_db_connections_threshold: 100
critical_db_connections_threshold: 200
alarm_action_list: ["arn:aws:sns:us-east-1:9783248248:MYALARM"]
credit_warning_threshold: 20
credit_critical_threshold: 10
replica_lag_threshold: 1800
roles:
- rds-alarms
限制
您需要为不同区域创建多个剧本。