Day 78 - Grafana Cloud: A Comprehensive Monitoring Solution๐ŸŒ

Nilkanth MistryNilkanth Mistry
4 min read

๐Ÿš€ 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.

  1. Navigate to the AWS Management Console. ๐Ÿ“‹

  2. Select "EC2" from the services menu. ๐ŸŒ

  3. 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 ๐Ÿ”—๐Ÿ”

  1. On the Grafana Cloud home page, navigate to the โ€œConnections/Add new connectionโ€ section. ๐Ÿ”—

  2. Click on โ€œAWSโ€ to access the setup for AWS account integration. ๐Ÿ”ง


Step 4: Select CloudWatch Metrics ๐Ÿ“Šโœจ

  1. In the dashboard, select CloudWatch metrics for integration between AWS and Grafana Cloud. ๐ŸŒ

  2. 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:

  1. Go to the AWS Management Console. ๐Ÿ“‹

  2. Select "IAM" from the services menu. ๐ŸŒ

  3. Click "Roles" and then "Create Role." ๐Ÿš€

  4. 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 ๐Ÿ“ˆ๐ŸŒŸ

  1. After successful integration, go to the home page and open the dashboard. ๐Ÿ 

  2. Select the CloudWatch Metrics dashboard to view visualized data with real-time tracking. ๐Ÿ•’๐Ÿ”


Step 7: Set Up Alerts for CPU Utilization ๐Ÿšจ๐Ÿ’ป

  1. Click on โ€œCreate Alert Ruleโ€ for CPU utilization above 75%. ๐Ÿ“Š

  2. Select the metric as_ec2_cpuutilization_maximum, then select the instance ID, and set the threshold value to 75%. ๐Ÿ“ˆ

  3. Run the query to check the output. ๐Ÿ”„

  4. Click โ€œSave Ruleโ€ to save the alert rule. ๐Ÿ’พ


Step 8: Configure Alerting Emails ๐Ÿ“ง๐Ÿ› ๏ธ

  1. Click on โ€œManage Contact Points.โ€ ๐Ÿ“‹

  2. Edit the grafana-default-email contact point. ๐Ÿ“

  3. Put your email address in the โ€œAddressโ€ field and click โ€œTestโ€ for verification. โœ”๏ธ

  4. You will receive a test alert email to confirm the setup. ๐Ÿ“ฌ


Step 9: Set Up Notification Policies ๐Ÿ“‘๐Ÿ“ง

  1. Click on โ€œManage Notification Policies.โ€ ๐Ÿ“‹

  2. Select the label and value for the notification (e.g., โ€œalertโ€ and โ€œcriticalโ€). ๐Ÿšจ

  3. Choose the contact point you previously created for alerting emails. โœ‰๏ธ


Step 10: Set Up Alerts for Billing ๐Ÿ’ธ๐Ÿ””

  1. Select โ€œManage Alert Rule.โ€ ๐Ÿ“‹

  2. Choose the metric aws_billing_estimated_charges_average and sum them. ๐Ÿ“Š

  3. Set the threshold value to $5. ๐Ÿ’ต

  4. 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. ๐ŸŒ๐Ÿš€

0
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