Grafana — Dashboards & Visualization
Observability
Chapter 5 · Grafana — Dashboards & Visualization
obs1-4 gave you PromQL. This chapter gives you somewhere to put it — Grafana, the visualization layer this course pairs with Prometheus. And in keeping with obs1-1's own opening warn-box, this chapter is honest about what a dashboard, no matter how well-built, actually is and isn't.
What Grafana Actually Is — A Visualization Layer, Not a Data Store
Grafana itself stores no metrics. It's a query-and-render frontend that connects to one or more data sources — Prometheus here, but also Loki for logs (obs1-7) and Jaeger/Tempo for traces (obs1-8) — and turns their query results into panels. This separation matters in practice: losing Grafana loses no actual data, since everything it displays lives in the underlying data source, not in Grafana itself. It also means one Grafana dashboard can show metrics, logs, and traces side by side, sourced from entirely different systems.
Data Sources — Connecting Grafana to Prometheus
A data source is configured once — a name, a type (Prometheus), and the URL Grafana should query. Once that connection exists, every panel in every dashboard can query it directly using ordinary PromQL, exactly as written in obs1-4.
Panels — The Basic Building Block
A panel is one visualization, backed by one or more queries. Common types: a time series graph, a single stat/number, a gauge, a table, and a heatmap — genuinely useful specifically for visualizing a histogram's own bucket distribution over time.
That's the exact error-rate query from obs1-4, dropped straight into a panel — a panel is nothing more than a chosen visualization wrapped around a PromQL query you already know how to write.
Template Variables — One Dashboard, Many Contexts
$service is a template variable — a dropdown at the top of the dashboard, typically populated by a label_values() query against Prometheus itself, that gets substituted into every panel's query at render time. One dashboard, built once, can then serve every service sharing that shape of metric — rather than hand-building a near-identical dashboard per service.
Dashboards as Code — Provisioning
Building a dashboard by clicking through Grafana's own UI works, but doesn't scale and isn't reviewable the way real code is. Grafana dashboards can instead be defined as JSON, checked into version control alongside application code — the same review-and-history discipline git1-3 already established for everything else. Provisioning is what makes this practical: Grafana can automatically load dashboard JSON and data source configuration from files at startup, rather than requiring anyone to manually recreate them through the UI — a light echo of k8s2-9's own GitOps pattern, applied here to dashboards instead of Kubernetes manifests.
An Honest Note — Dashboards Are Still Monitoring, Not Observability
obs1-1's own warn-box applies here directly: a dashboard, however well-designed, only ever answers the questions its panels were built to answer in advance. Grafana's Explore mode is its own genuine answer to that limit — an interface for running ad-hoc PromQL queries against a data source without needing a saved panel first, letting you follow a brand-new question on the spot during an incident rather than being limited to whatever panels already exist.
| Good for | Limitation | |
|---|---|---|
| A fixed dashboard | Recurring, anticipated questions — daily health checks, known failure modes | Only answers what its panels were built to answer |
| Explore mode | An unanticipated question, mid-incident, right now | Not saved or shared by default — built for exploration, not a recurring view |
git1-3 and tf1 already established for everything else.
Hands-On Exercises
Explain why deleting a Grafana dashboard doesn't delete any actual metrics data, and what this reveals about the relationship between Grafana and a data source like Prometheus.
📄 View solutionA team has 15 near-identical dashboards, one per microservice, each hand-built with the same panels. Explain how a template variable would let this become a single dashboard instead, and write the PromQL a request-rate panel would use with that variable.
📄 View solutionDuring an incident, an engineer needs to answer a question no existing dashboard panel covers. Explain which Grafana feature is built for exactly this situation, and why a fixed dashboard alone wouldn't have been enough — tying your answer back to obs1-1's own monitoring-vs-observability distinction.
📄 View solutionChapter 5 Quick Reference
- Grafana stores no data itself — it queries data sources (Prometheus, Loki, Jaeger/Tempo) and renders the results
- A panel is one visualization backed by a query — a PromQL query from Chapter 4 dropped straight in
- Template variables (e.g. $service) let one dashboard serve many contexts instead of duplicating dashboards
- Provisioning loads dashboard JSON and data source config from files at startup — dashboards as version-controlled code
- A dashboard only answers questions its panels were built to answer; Explore mode supports genuinely new, unanticipated questions
- Too many panels on one dashboard is a real anti-pattern — fewer, well-chosen panels beat comprehensive-but-noisy ones