Skip to content

Instantly share code, notes, and snippets.

@naavveenn
Created May 3, 2018 07:25
Show Gist options
  • Save naavveenn/595b492fd54b6665e519815226ce040b to your computer and use it in GitHub Desktop.
Save naavveenn/595b492fd54b6665e519815226ce040b to your computer and use it in GitHub Desktop.
---
- hosts: local
connection: local
vars_files:
- /home/ansible/awscreds.yml # contains var info as mention in comment
tasks:
- name: Get DB instance name
shell: aws rds describe-db-instances --query DBInstances[*].DBInstanceIdentifier --region "{{ aws_region }}" --output text | tr "\t" "\n" > "{{ path }}"
register: rds_instances
- name: Creating Alarms for RDS
ec2_metric_alarm:
aws_access_key: "{{ aws_id }}"
aws_secret_key: "{{ aws_key }}"
region: "{{ aws_region }}"
state: present
name: "msp-{{ type }}-{{ metric_name }}-{{ item }}"
metric: "{{ metric_name }}"
namespace: "{{ namespace }}"
statistic: "{{ stats }}"
comparison: "{{ comparison }}"
threshold: "{{ threshold_value }}"
period: "{{ period }}"
evaluation_periods: 1
unit: "{{ unit }}"
description: "High {{ metric_name }} for {{ item }} - {{ type }}"
dimensions: {'DBInstanceIdentifier': "{{ item }}"}
alarm_actions: "{{ sns_arn }}"
with_lines:
- cat "{{ path }}"
@naavveenn
Copy link
Author

aws_id: ABC
aws_key: ABC
aws_region: ap-south-1
type: warning
metric_name: "FreeableMemory"
namespace: "AWS/RDS"
stats: Average
comparison: ">="
threshold_value: 15
period: 300
unit: "Bytes"
sns_arn: ['arn:aws:sns:ap-south-1:984448784512:Testing']
path: /home/ansible/rds_output.txt

##Metric: DatabaseConnections,
##Unit: Count

##Metric: CPUUtilization,
##Unit:Percent

##Metric: FreeableMemory,FreeStorageSpace BinLogDiskUsage
##Unit: Bytes
##Comparison: "<="

##Metric: BinLogDiskUsage
##Unit: Bytes

##ReplicaLag
##Unit: Seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment