Getting Started with Prometheus and Grafana
Monitoring is one of the most important parts of running modern applications. Whether you’re managing microservices, Docker containers, or cloud infrastructure, understanding what’s happening inside your system is crucial.
In this blog, we’ll explore Prometheus and Grafana—two of the most popular open-source monitoring tools. By the end, you’ll know how they work, how to set them up, and how to build beautiful dashboards.
🔍 What is Prometheus?
Prometheus is an open-source time-series database and monitoring system. It collects metrics from your applications and stores them so you can analyze performance over time.
Key Features of Prometheus
Pull-based scraping model
Powerful PromQL query language
Alerting support via Alertmanager
Easy integration with Kubernetes, Docker, Node.js, Go, Python, etc.
Lightweight and high performance
📊 What is Grafana?
Grafana is an open-source visualization and dashboarding tool. It connects with data sources like Prometheus to show beautiful charts, graphs, and alerts.
Why Grafana?
Supports 30+ data sources
Ready-made dashboard templates
Custom alerts
Permissions and sharing features
Modern and intuitive UI
🧩 How Prometheus and Grafana Work Together
Prometheus scrapes metrics from your app or server.
Metrics get stored in Prometheus as time-series data.
Grafana connects to Prometheus as a data source.
You visualize the metrics using dashboards and graphs.
This combination gives you full monitoring + visualization.
⚙️ Installing Prometheus and Grafana Using Docker
If you want a simple setup, Docker is the easiest way:
1. Create docker-compose.yml
version: '3.7'
services:
prometheus:
image: prom/prometheus
container_name: prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
grafana:
image: grafana/grafana
container_name: grafana
ports:
- "3000:3000"
2. Create Prometheus config file (prometheus.yml)
global:
scrape_interval: 5s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
3. Start services
docker compose up -d
That’s it!
Prometheus → http://localhost:9090
Grafana → http://localhost:3000 (default login: admin / admin)
📈 Adding Prometheus as a Grafana Data Source
Log in to Grafana
Go to Settings → Data Sources
Click Add Data Source
Choose Prometheus
Set URL:
http://prometheus:9090orhttp://localhost:9090Save & Test
📌 Creating Dashboards in Grafana
Grafana gives you many ways to visualize data:
Line graphs
Bar charts
Heatmaps
Gauges
Stat panels
Example: CPU Usage Query (Node Exporter)
rate(node_cpu_seconds_total{mode!="idle"}[5m])
Example: Memory Usage Query
node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100
Once you add a panel, you can customize:
Colors
Legends
Thresholds
Refresh intervals
🚨 Setting Up Alerts
You can configure alerts in either:
⚡ Prometheus → Alertmanager
🌈 Grafana → Alert rules inside dashboards
Grafana alerts are easier:
Open a panel
Click Alerts → Create Alert Rule
Set conditions (e.g., CPU > 80%)
Add notification channels (email, Slack, Webhooks)
📦 Exporters You Must Know
Exporters help Prometheus collect metrics. Popular options:
System Metrics
- Node Exporter → CPU, RAM, disk, network
Containers
- cAdvisor → Docker container metrics
Databases
MySQL Exporter
PostgreSQL Exporter
Redis Exporter
Applications
Node.js Prometheus client
Python
prometheus_clientGo
prometheuslibrary
🎯 Final Thoughts
Prometheus + Grafana is the perfect monitoring stack for:
DevOps engineers
Backend developers
Cloud-native apps
Kubernetes clusters
Self-hosted servers
It’s open-source, powerful, and easy to use once you understand the basics.
If you're building scalable apps, real-time monitoring is not optional—it's essential.

