๐ How to Install Grafana on the Same AWS EC2 Instance as Prometheus


Series: 30 Days DevOps Interview Preparation
Author: Tathagat Gaikwad
In the previous blog, we set up Prometheus on an AWS EC2 instance for monitoring metrics.
Now, letโs add Grafana on the same server so we can visualize Prometheus data using beautiful dashboards.
๐น 1. Why Grafana with Prometheus?
Prometheus collects and stores metrics, but its built-in UI is limited. Grafana enhances monitoring with:
Rich dashboards & graphs
Alerts with flexible rules
Easy integration with Prometheus, AWS, MySQL, and many more data sources
Together, Prometheus + Grafana form a powerful monitoring stack.
๐น 2. Pre-requisites
AWS EC2 instance (Ubuntu 20.04/22.04)
Prometheus already installed and running on
:9090
Security group open for:
22
โ SSH9090
โ Prometheus3000
โ Grafana (default port)
๐น 3. Install Grafana on Ubuntu EC2
Step 1: Add Grafana APT Repository
sudo apt-get install -y apt-transport-https software-properties-common
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
Step 2: Install Grafana
sudo apt update
sudo apt install grafana -y
Step 3: Start and Enable Grafana Service
sudo systemctl daemon-reload
sudo systemctl enable --now grafana-server
sudo systemctl status grafana-server
๐น 4. Access Grafana Web UI
Open your browser โ
http://<EC2-PUBLIC-IP>:3000
Default credentials:
Username:
admin
Password:
admin
(youโll be prompted to change it)
๐น 5. Connect Grafana with Prometheus
Go to Configuration โ Data Sources โ Add data source.
Select Prometheus.
Enter URL:
http://localhost:9090
Click Save & Test โ you should see Data source is working.
๐น 6. Import Pre-built Dashboards
Grafana provides 1000+ ready-to-use dashboards.
Go to Dashboards โ Import.
Paste Dashboard ID (e.g., 1860 for Node Exporter Full).
Select your Prometheus data source โ Click Import.
Now youโll see system metrics, CPU, memory, disk, and network usage beautifully visualized.
๐น 7. Security Best Practices
Change the admin password immediately.
Update Security Group rules โ allow
3000
only for trusted IPs.Optionally set up Nginx reverse proxy with HTTPS for secure Grafana access.
๐น 8. Next Steps
Configure Alerting in Grafana or Prometheus Alertmanager.
Explore CloudWatch integration to pull AWS metrics into Grafana.
Set up Dashboards for specific services like MySQL, Docker, Kubernetes.
โ With this setup, you now have Prometheus + Grafana running on a single AWS EC2 instance. Prometheus scrapes metrics, and Grafana visualizes them in real-time.
Subscribe to my newsletter
Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
