This is a complete, hands-on Grafana cheat sheet: install, configure, operate, automate and secure it - with copy-paste commands grouped by task. Bookmark it for day-to-day work, incidents and interviews alike.
Grafana visualizes data from Prometheus, Loki, Elasticsearch and dozens of other sources in shared dashboards, and unifies alerting across them - dashboards defined as code where you want it.
Why you reach for it
- One pane of glass across metrics, logs and traces
- Dashboards and alerts as code (provisioning) for reproducibility
- A vast library of community dashboards to start from
Installation
docker run -d -p 3000:3000 --name grafana grafana/grafana-oss
# default login admin/admin on http://localhost:3000Configuration reference
Provision a data source as code so it is reproducible.
# provisioning/datasources/prometheus.yaml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: trueCore commands you use daily
# Export a dashboard as JSON so it can be version controlled
curl -s -H "Authorization: Bearer $KEY" \
http://localhost:3000/api/dashboards/uid/abc123 | jq .dashboard > dash.jsonHTTP API
curl -s -H "Authorization: Bearer $KEY" http://localhost:3000/api/dashboards/uid/abc | jq .dashboard > dash.json
curl -s -X POST -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
-d @dash.json http://localhost:3000/api/dashboards/dbCLI & provisioning
grafana-cli plugins install grafana-piechart-panel
# provisioning paths mounted into the container:
# /etc/grafana/provisioning/datasources/*.yaml
# /etc/grafana/provisioning/dashboards/*.yamlUse it in CI/CD
Ship dashboards from Git via provisioning.
# provisioning/dashboards/all.yaml
apiVersion: 1
providers:
- name: git-dashboards
folder: Services
type: file
options: { path: /var/lib/grafana/dashboards }Best-practice checklist
- Provision data sources and dashboards as code from Git
- Design a few focused dashboards per service, not one giant wall
- Standardize variables and folders so teams find things fast
Common pitfalls to avoid
- Click-built dashboards that live only in the database and vanish on rebuild
- Overloaded dashboards nobody can read during an incident
- Alerting split between Grafana and other tools with no clear owner
Security quick wins
- Use SSO/OAuth and per-team folders with RBAC
- Create read-only API keys for automation
Works well with
- Prometheus - The de-facto standard for metrics - a pull-based time-series database with a powerful query language.
- Grafana Loki - Prometheus-style log aggregation that indexes labels, not full text - cheap and Grafana-native.
- Elasticsearch - A distributed search and analytics engine for logs, full-text search and (now) vectors.
A cheat sheet is muscle memory on paper - keep it close until the commands live in your fingers.
Want senior help putting Grafana to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.