AWS, Cloud Computing, DevOps

4 Mins Read

A Guide to Automate the Creation of Amazon CloudWatch Alarms using Ansible

Voiced by Amazon Polly

Overview

Monitoring is one of the key factors for analyzing the Resource performance and identifying any underlying issues or debugging instance performance. It’s also helping us to set up a reliable, cost-effective Infrastructure. Integration of Ansible and AWS Systems Manager to automate the Monitor creation will provide a smooth deployment model. 

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Introduction

Amazon CloudWatch is one of the most widely used Monitoring tools for AWS resources. Its integration with AWS services provides more reliability and accuracy while monitoring service performances.

Monitoring Amazon EC2 instances is crucial for detecting any underlying issues or debugging instance performance early. Amazon CloudWatch is a stable, scalable, and adaptable monitoring solution. Customers who run Amazon EC2 instances in a self-managed environment often use Amazon CloudWatch metrics to monitor instance performance and set up alarms for key performance indicators to warn them of any difficulties based on the thresholds they designate. Amazon CloudWatch agent is used in some cases to monitor custom metrics.

Amazon CloudWatch dashboards offer flexible home pages in the Amazon CloudWatch console that you may use to monitor your resources in a single perspective, even if they are dispersed across multiple Regions. Amazon CloudWatch dashboards can be used to build personalized views of metrics and alarms for your AWS services. Alarms can be added to dashboards to monitor and get notifications about your AWS resources and applications across various Regions.

In this blog, we will automate the creation process of Amazon CloudWatch Alarms creation using the help of Ansible and AWS Systems Manager.

Step-by-Step Guide

Step 1: Integration of Amazon EC2 Instance with AWS Systems Manager

  • Create IAM Role for AWS Systems Manager Association
  • Go to the IAM console and select Role
  • Now click on Create Role
  • Select the trusted entity and select Amazon EC2

step1

  • Select AmazonSSMManagedInstanceCore policy and AmazonSSMFullAccess

step1b

  • Provide a suitable name and create the role.
  • Associate the created AWS IAM Role to our Amazon EC2 Instance. Select the Amazon EC2 Instance and click on Actions -> Security and then Modify IAM Role

step1c

  • Select the AWS IAM Role and Update the AWS IAM role

step1d

step1e

  • Go to AWS Systems Manager and select Fleet Manager. Now you can view the Managed Instances there.

step1f

Step 2: Installation of Ansible on Amazon EC2 Instance

step2

  • Verify that Ansible is Installed correctly by running a simple playbook

step2b

  • If you got the above output, then Ansible is installed correctly.

Step 3: Download code from GitHub Repo

step3

step3b

Step 4: Configure AWS State Manager

  • Go to AWS Systems Manager then go to Systems Manager, then click on “Create Association”
  • Select Document “AWS-ApplyAnsiblePlaybooks” then select Amazon S3 as the source type,
  • “Source info” as { “path”:”https://s3.amazonaws.com/<s3 bucket name>” }
  • In the example, snippet below, “Source info” is set as { “path”:”https://s3.amazonaws.com/ansible-cloudwatch-blog” }
  • Select true as Install Dependencies.
  • Provide playbook file as amazon-cloudwatch-dashboard-alarms-with-ssm-ansible-role-main/playbook.yml

step4

  • Select the Instance manually.

step4b

  • Then click on Create Association.
  • Now you can view your CloudWatch Alarm in the Alarm section,

step4c

Conclusion

Monitoring is important nowadays to understand and troubleshoot the underlying issues of Infrastructure. This demo shows how we can automate the process of creating Amazon CloudWatch Alarm by eliminating manual Interventions.

Drop a query if you have any questions regarding Amazon CloudWatch Alarm and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAWS GenAI Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery Partner AWS Microsoft Workload PartnersAmazon EC2 Service Delivery PartnerAmazon ECS Service Delivery PartnerAWS Glue Service Delivery PartnerAmazon Redshift Service Delivery PartnerAWS Control Tower Service Delivery PartnerAWS WAF Service Delivery PartnerAmazon CloudFront Service Delivery PartnerAmazon OpenSearch Service Delivery PartnerAWS DMS Service Delivery PartnerAWS Systems Manager Service Delivery PartnerAmazon RDS Service Delivery PartnerAWS CloudFormation Service Delivery PartnerAWS ConfigAmazon EMR and many more.

FAQs

1. What are the target configuration options?

ANS: – You can choose to target instances or tags. This implies you can have different configurations for different sets of instances, such as web servers.

2. What are the benefits of using AWS Systems Manager state manager?

ANS: – It isn’t easy to ensure that the infrastructure that powers your applications is consistent. AWS Systems Manager enables you to set policies, reapply them to minimize configuration drift, and monitor the status of your desired state.

3. Can I run AWS Systems Manager automation playbook steps sequentially?

ANS: – Yes, you can execute the whole AWS Systems Manager automation playbook at once or one step at a time using the manual execution method.

WRITTEN BY Deepak Surendran

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!