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.

# A panel's query is just PromQL — everything from Chapter 4 transfers directly sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) * 100

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

sum(rate(http_requests_total{job="$service"}[5m]))

$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 forLimitation
A fixed dashboardRecurring, anticipated questions — daily health checks, known failure modesOnly answers what its panels were built to answer
Explore modeAn unanticipated question, mid-incident, right nowNot saved or shared by default — built for exploration, not a recurring view
Version-control dashboard JSON the same way you version-control code
A dashboard that only exists as manual clicks inside Grafana's own UI has no history, no review process, and no way to recover if someone accidentally breaks it. Provisioning dashboards from JSON files kept in the same repository as the application they monitor gives dashboards the exact same discipline this site's own git1-3 and tf1 already established for everything else.
A dashboard crammed with panels becomes noise, not signal
Cramming every metric that exists onto one screen "just in case" is a real, common anti-pattern — the resulting dashboard is technically comprehensive and practically useless, since nothing on it stands out during an actual incident. A small number of well-chosen panels, built to answer one specific operational question, beats an everything-at-once dashboard every time.

Hands-On Exercises

Exercise 1

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 solution
Exercise 2

A 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 solution
Exercise 3

During 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 solution

Chapter 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