๐Ÿ“Š 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 โ†’ SSH

    • 9090 โ†’ Prometheus

    • 3000 โ†’ 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

  1. Go to Configuration โ†’ Data Sources โ†’ Add data source.

  2. Select Prometheus.

  3. Enter URL:

     http://localhost:9090
    
  4. Click Save & Test โ†’ you should see Data source is working.


๐Ÿ”น 6. Import Pre-built Dashboards

Grafana provides 1000+ ready-to-use dashboards.

  1. Go to Dashboards โ†’ Import.

  2. Paste Dashboard ID (e.g., 1860 for Node Exporter Full).

  3. Select your Prometheus data source โ†’ Click Import.

  4. 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.

0
Subscribe to my newsletter

Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tathagat Gaikwad
Tathagat Gaikwad