Day 78 - Grafana Cloud: A Comprehensive Monitoring Solution๐
๐ Welcome to Day 78 of the 90 Days of DevOps Challenge! ๐
Today, we dive into Grafana Cloud, a robust and scalable monitoring platform that provides comprehensive monitoring capabilities for your infrastructure, applications, and cloud resources. With Grafana Cloud, you can consolidate all your monitoring needs into a single platform, gaining real-time visibility into the performance and health of your systems. The platformโs intuitive interface and powerful features make it an ideal choice for DevOps teams to effectively monitor their environments. ๐
Task: Setting Up Alerts for EC2 Instances and AWS Billing Alerts
Step 1: Create an EC2 Instance ๐ฅ๏ธโจ
Start by creating an EC2 instance in your AWS environment. This instance will be monitored using Grafana.
Navigate to the AWS Management Console. ๐
Select "EC2" from the services menu. ๐
Click "Launch Instance" and follow the steps to configure and start your instance. ๐
Step 2: Set Up Grafana Cloud Console โ๏ธ๐ง
If you havenโt set up Grafana Cloud yet, follow the steps in my previous blog post on how to set up Grafana Cloud. Ensure your Grafana Cloud instance is running and accessible. โ
install Grafana:
sudo apt-get update
sudo apt install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo apt update
sudo apt install -y grafana
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
Step 3: Connect Data to AWS ๐๐
On the Grafana Cloud home page, navigate to the โConnections/Add new connectionโ section. ๐
Click on โAWSโ to access the setup for AWS account integration. ๐ง
Step 4: Select CloudWatch Metrics ๐โจ
In the dashboard, select CloudWatch metrics for integration between AWS and Grafana Cloud. ๐
Follow the prompts to complete the setup. ๐ ๏ธ
Step 5: Create AWS IAM Role ๐๐ง
For CloudWatch integration, you need to create an AWS IAM Role. Follow these steps:
Go to the AWS Management Console. ๐
Select "IAM" from the services menu. ๐
Click "Roles" and then "Create Role." ๐
Follow the steps in the screenshot provided in your Grafana setup guide to set up the IAM Role via CloudFormation. ๐ท
Step 6: Access CloudWatch Metrics Dashboard ๐๐
After successful integration, go to the home page and open the dashboard. ๐
Select the CloudWatch Metrics dashboard to view visualized data with real-time tracking. ๐๐
Step 7: Set Up Alerts for CPU Utilization ๐จ๐ป
Click on โCreate Alert Ruleโ for CPU utilization above 75%. ๐
Select the metric
as_ec2_cpuutilization_maximum
, then select the instance ID, and set the threshold value to 75%. ๐Run the query to check the output. ๐
Click โSave Ruleโ to save the alert rule. ๐พ
Step 8: Configure Alerting Emails ๐ง๐ ๏ธ
Click on โManage Contact Points.โ ๐
Edit the
grafana-default-email
contact point. ๐Put your email address in the โAddressโ field and click โTestโ for verification. โ๏ธ
You will receive a test alert email to confirm the setup. ๐ฌ
Step 9: Set Up Notification Policies ๐๐ง
Click on โManage Notification Policies.โ ๐
Select the label and value for the notification (e.g., โalertโ and โcriticalโ). ๐จ
Choose the contact point you previously created for alerting emails. โ๏ธ
Step 10: Set Up Alerts for Billing ๐ธ๐
Select โManage Alert Rule.โ ๐
Choose the metric
aws_billing_estimated_charges_average
and sum them. ๐Set the threshold value to $5. ๐ต
Add a new notification policy for billing above $5. ๐ง
๐ Congratulations! Youโve now set up monitoring and alerting for your EC2 instances and AWS billing in Grafana Cloud. With Grafana Cloudโs powerful monitoring capabilities, you can proactively respond to issues and ensure the optimal performance of your infrastructure. ๐๐
Subscribe to my newsletter
Read articles from Nilkanth Mistry directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Nilkanth Mistry
Nilkanth Mistry
Embark on a 90-day DevOps journey with me as we tackle challenges, unravel complexities, and conquer the world of seamless software delivery. Join my Hashnode blog series where we'll explore hands-on DevOps scenarios, troubleshooting real-world issues, and mastering the art of efficient deployment. Let's embrace the challenges and elevate our DevOps expertise together! #DevOpsChallenges #HandsOnLearning #ContinuousImprovement