What Grafana Does
- Dashboards: Build interactive dashboards with 50+ panel types (graphs, gauges, tables, heatmaps, maps)
- Data Sources: Connect 100+ data sources including Prometheus, InfluxDB, Elasticsearch, PostgreSQL, MySQL, Loki, Tempo, and cloud services
- Alerting: Define alert rules, notification channels (Slack, PagerDuty, email), and escalation policies
- Explore: Ad-hoc query interface for investigating metrics and logs in real-time
- Annotations: Mark events on graphs (deploys, incidents, changes) for correlation
- Variables: Template variables for dynamic, reusable dashboards
- Provisioning: Infrastructure-as-code dashboard and datasource management via YAML/JSON
Architecture
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Browser │────▶│ Grafana │────▶│ Data Sources│
│ Dashboard │ │ Server (Go) │ │ Prometheus │
└──────────────┘ └──────────────┘ │ InfluxDB │
│ Elasticsearch│
│ PostgreSQL │
│ Loki (Logs) │
│ Tempo (Traces)│
└──────────────┘Self-Hosting
Docker Compose with Prometheus
services:
grafana:
image: grafana/grafana-oss:latest
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: your-password
volumes:
- grafana-data:/var/lib/grafana
depends_on:
- prometheus
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
volumes:
grafana-data:
prometheus-data:Key Features
Dashboard Panels
Available panel types:
├── Time Series — line/area/bar charts over time
├── Stat — single value with sparkline
├── Gauge — circular gauge with thresholds
├── Bar Chart — categorical comparisons
├── Table — tabular data with sorting/filtering
├── Heatmap — time-based density visualization
├── Geomap — geographic data on world map
├── Logs — log line viewer with search
├── Traces — distributed trace visualization
├── Node Graph — network topology
├── Canvas — custom layout with drag-and-drop
└── 40+ more community panelsPromQL Example (Prometheus)
# CPU usage per container
rate(container_cpu_usage_seconds_total{namespace="production"}[5m]) * 100
# Request rate
sum(rate(http_requests_total[5m])) by (status_code)
# P99 latency
histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m]))
# Error rate percentage
sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) * 100Alerting
# Alert rule example
groups:
- name: critical
rules:
- alert: HighErrorRate
expr: sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) > 0.05
for: 5m
labels:
severity: critical
annotations:
summary: "Error rate above 5%"Dashboard as Code
{
"dashboard": {
"title": "My Dashboard",
"panels": [
{
"title": "CPU Usage",
"type": "timeseries",
"datasource": "Prometheus",
"targets": [
{
"expr": "rate(node_cpu_seconds_total{mode='idle'}[5m])",
"legendFormat": "{{instance}}"
}
]
}
]
}
}LGTM Stack (Full Observability)
Grafana Labs provides a complete open-source observability stack:
| Component | Purpose | Data Type |
|---|---|---|
| Grafana | Visualization | Dashboards |
| Loki | Log aggregation | Logs |
| Tempo | Distributed tracing | Traces |
| Mimir | Metrics storage | Metrics |
| Alloy | Telemetry collector | Collection |
Grafana vs Alternatives
| Feature | Grafana | Kibana | Datadog | New Relic |
|---|---|---|---|---|
| Open Source | Yes (AGPL-3.0) | Yes (Elastic) | No | No |
| Self-hosted | Yes | Yes | No | No |
| Data sources | 100+ | Elasticsearch | Proprietary | Proprietary |
| Alerting | Built-in | Built-in | Built-in | Built-in |
| Pricing | Free (OSS) | Free (Basic) | $15/host/mo | $0.30/GB |
FAQ
Q: Is Grafana beginner-friendly? A: Grafana itself has a gentle learning curve — drag panels and pick a data source. The challenge is understanding the data source (e.g., Prometheus's PromQL). Start by importing community dashboards.
Q: Grafana OSS vs Grafana Cloud? A: OSS is the fully free, self-hosted version. Cloud is the managed service, with a free tier including 10K metrics / 50GB logs / 50GB traces. Cloud also adds some features missing from OSS, such as ML-powered alerting.
Q: Can I embed it in my own app? A: Yes. Grafana supports iframe embedding and anonymous access configuration. You can also use Grafana's API to capture panel screenshots.