Dashboards that answer questions
Start from the question the on-call will ask, build overview, service and drill-down layers that answer it in order, and keep the result in version control
The page says 'gateway error ratio above 1%'. Which dashboard gets the on-call to the failing service fastest?
The RED chapter gave you a dashboard per service and one for the host. The histogram chapter made their latency panels correct. This chapter turns that pile into something an on-call can use under stress: fewer panels, each answering a named question, linked in the order the questions get asked.
A dashboard is an answer to a question
The failure mode has a name: wallpaper. A dashboard that grows by accretion, one panel per incident (“we should have been watching this”), ends up watching everything and answering nothing. It looks impressive on a TV and it is slow to read in an incident, because reading it means deciding which of 40 panels matters right now, and that decision is the work the dashboard was supposed to do for you.
The test for every panel is two sentences. What question does it answer? What would you do differently depending on the answer? “Is the gateway failing requests? If yes, find out where; if no, the page is a false alarm” passes. “Host 7 CPU” does not, until you can say what a high value would make you do, and usually the answer is “check whether p99 moved”, which means the p99 panel is the one that belongs on the overview and host 7 CPU belongs a layer down.
Write the questions down before you build anything. For the demo app they are:
- Are users hurt right now? (gateway errors and latency)
- How much traffic is there, compared with normal? (gateway rate)
- Which service is responsible? (errors and latency by service)
- Is anything about to break? (saturation)
- What exactly is wrong in that service? (its RED dashboard)
- Which resource, route or request is the cause? (USE, traces, logs)
Questions 1 to 4 are the overview. Question 5 is the service layer. Question 6 is drill-down. That ordering is the hierarchy.
Overview, service, drill-down
The Grafana best-practice guide calls this hierarchical dashboards with drill-down, and it is the single change that does most for incident response.
Overview. One per user-facing product, not one per team. Six to eight panels, readable without scrolling on a laptop screen. It answers “is anyone hurt, and where?” Every panel is either a symptom at the edge (RED for the gateway) or a breakdown that points to the next layer (errors by service). Nothing here is a cause.
Service. One dashboard per service, all with the same shape, parameterised by a job template variable rather than copied. RED first, in the same order as everywhere else, then the service’s saturation (pool usage, in-flight requests, queue depth), then its dependencies’ RED as the service sees them (the client-side view). It answers “what is wrong with this service?”
Drill-down. Whatever explains the cause: the host’s USE dashboard, per-route latency, slow queries from the database chapter, logs in Loki, traces in Tempo. Most of these are not dashboards at all but Explore views reached by a link with the right query already filled in.
The layers only work if the links between them carry context. Clicking payments on the overview must open the service dashboard filtered to payments, over the same time range, without the on-call retyping anything. Grafana has three mechanisms for that:
| Mechanism | Lives on | Carries | Use it for |
|---|---|---|---|
| Dashboard link | the dashboard header | the time range and, optionally, variable values | “up a level” and “sideways” links that always apply |
| Data link | a panel’s series or value | the clicked series’ labels, its value, its time, the time range | the drill-down: click a service, get that service |
| Exemplar | a point on a histogram panel | a trace id recorded with that observation | jump from a latency spike to one real slow trace |
A data link URL is a template. The variables you need most are ${__field.labels.job} (a label of the series you clicked; labels with dots use ${__field.labels["service.name"]}), ${__url_time_range} (the dashboard’s time range as query parameters) and ${__value.time} (the timestamp of the point under the cursor). The link from the overview’s “errors by service” panel to the service dashboard is:
/d/service-red/service-red?var-job=${__field.labels.job}&${__url_time_range}
Exemplars connect the histogram you built in the previous chapter to the trace that produced a point in it. Prometheus stores them only with --enable-feature=exemplar-storage, the Collector’s Prometheus exporter exposes them only in OpenMetrics format (enable_open_metrics: true), and the Grafana Prometheus data source needs its Exemplars section pointed at Tempo with the label name trace_id. Then each point on a latency panel can carry a highlighted marker whose hover shows a trace id and a button that opens the trace. The tracing chapter in O3 makes this the main debugging path; for now it is enough to know the overview’s p99 panel is where it goes.
Template variables
Copying a dashboard per service is how one dashboard becomes thirty that drift apart. A template variable replaces the copies with one dashboard and a drop-down.
For the demo app, the service dashboard needs one variable, job, of type Query, with the Prometheus query
label_values(http_server_request_duration_seconds_count, job)
and every panel query filters on job="$job". Add a data source variable too (type Data source, Prometheus) and reference it as the panel data source, so the same dashboard JSON works against a staging Prometheus or a Grafana Cloud stack without edits.
Multi-value variables need care. With Multi-value or Include All on, $job interpolates to a regex alternation, so the filter must be job=~"$job" with a tilde, and the panel should group by (job) or the series will silently sum across the selected services. If you want All to mean “every service” without Grafana expanding it into a long alternation, set Custom all value to .+.
$__rate_interval is a built-in variable, not one you define: Grafana sets it to max($__interval + scrape interval, 4 × scrape interval), where the scrape interval comes from the data source’s Scrape interval setting (15 s by default). Use it in every rate() on a dashboard. A hard-coded [1m] works until someone zooms out to seven days and gets a jagged line, or until the scrape interval changes to 30 s and [1m] covers two samples.
Units, colours and consistency
The on-call reads a dashboard in a hurry, half-awake, comparing panels with each other. Every inconsistency is a chance to misread.
- Units. Set the unit on every panel: seconds for latency (Grafana renders 0.25 s as 250 ms automatically), Percent (0.0-1.0) for ratios, requests/sec for rate. Never mix milliseconds and seconds across panels that will be compared. The most common incident-time misreading is a “p99 = 2.5” that one person reads as milliseconds and another as seconds.
- Colour means something. Red is bad, and only bad. Thresholds on the error panel at the alert threshold (1%) and on the p99 panel at the SLO (500 ms) mean the overview turns red exactly when a page would fire. A palette of eight cheerful colours on a panel where nothing is wrong teaches people that colour carries no information.
- Same order, same place. Rate, errors, duration, saturation, left to right, on every service dashboard. When the order is fixed, the eye goes to the second panel for errors without reading titles.
- Like with like. Do not put a 2,000 rps service and a 5 rps service on one axis; the small one becomes a flat line at zero. Split them, or plot ratios and percentiles, which are comparable across sizes.
- Descriptions. Every panel has a description (the ⓘ on hover) that says what the query measures and what to do when it is red. It costs one sentence and saves the 2 am “what does this mean?”.
The 40-panel dashboard, and how to shrink it
Shrinking a wallpaper dashboard is mostly deletion, and deletion needs a method or it stalls on “but someone might need it”. Go panel by panel:
- Write the question it answers. If you cannot, delete it.
- If the question is a symptom at the edge, it stays on the overview.
- If it is a breakdown that points to the next layer, it stays on the overview with a data link, or merges into an existing breakdown (twelve per-host CPU panels become one panel with twelve series, or better, one “top 3 hosts by CPU saturation” panel using
topk). - If it is a cause, it moves to the service or drill-down layer.
- If it duplicates another panel with a different query, keep the one whose query is correct (the merged histogram, not the averaged p99) and delete the other.
The Grafana guide adds two habits: show what is in trouble, not everything, and link most dashboards from alerts, so that dashboards nobody links to become candidates for deletion. Grafana Enterprise and Grafana Cloud record views per dashboard (usage insights); a dashboard with no views in 90 days is wallpaper by definition. On open-source Grafana, a dashboard that no alert and no other dashboard links to is the same signal.
Dashboards as code
A dashboard edited in the UI has no history, no review and no way back after someone’s well-meant change at 3 am. The Grafana maturity model puts “dashboard JSON in version control” in the middle tier and “stop editing in the browser, generate dashboards from code” at the top.
There are three levels of doing this.
Provisioned JSON. Grafana reads dashboard JSON from disk at start-up and every updateIntervalSeconds thereafter, as configured by a provider file:
apiVersion: 1
providers:
- name: atlas-lab
type: file
updateIntervalSeconds: 10
allowUiUpdates: false
options:
path: /var/lib/grafana/dashboards
foldersFromFilesStructure: true
The lab’s provider, grafana/provisioning/dashboards/dashboards.yaml, has the same name and path, with allowUiUpdates: true so you can experiment; compose mounts grafana/dashboards/ at that path.
You build in the UI, export (Export → Export as code, with “Share dashboard with another instance” switched off so data source uids stay real), commit the JSON, and the next Grafana loads it. allowUiUpdates: false stops anyone saving changes in the UI that the next reload would silently overwrite. Grafana strips the numeric id from exported JSON; the string uid is what links and provisioning key on, so set it by hand to something readable and keep it unique.
Grafonnet. A Jsonnet library, now generated from the same schemas as the Foundation SDK. It suits teams already using Jsonnet for Kubernetes or Prometheus mixins. Its own README calls it experimental.
The Grafana Foundation SDK. Typed builders for dashboards in Go, TypeScript, Python, PHP and Java, targeting Grafana 10 and later and best with 12. The value is the function: a red_dashboard(service) that every one of thirty services calls, so the layout is defined once.
# python3 -m pip install grafana_foundation_sdk
from grafana_foundation_sdk.builders.dashboard import Dashboard
from grafana_foundation_sdk.builders.prometheus import Dataquery as PromQuery
from grafana_foundation_sdk.builders.timeseries import Panel as Timeseries
from grafana_foundation_sdk.cog.encoder import JSONEncoder
M = "http_server_request_duration_seconds"
def red(job: str) -> Dashboard:
total = f'sum(rate({M}_count{{job="{job}"}}[$__rate_interval]))'
errors = f'sum(rate({M}_count{{job="{job}", http_response_status_code=~"5.."}}[$__rate_interval]))'
p99 = f'histogram_quantile(0.99, sum by (le) (rate({M}_bucket{{job="{job}"}}[$__rate_interval])))'
return (Dashboard(f"{job} RED").uid(f"{job}-red").tags(["red", "generated"])
.with_panel(Timeseries().title("Rate").unit("reqps").with_target(PromQuery().expr(total)))
.with_panel(Timeseries().title("Errors").unit("percentunit").with_target(PromQuery().expr(f"{errors} / {total}")))
.with_panel(Timeseries().title("Duration p99").unit("s").with_target(PromQuery().expr(p99))))
for job in ["gateway", "orders", "payments"]:
with open(f"{job}-red.json", "w") as f:
f.write(JSONEncoder(sort_keys=True, indent=2).encode(red(job).build()))
Whichever you choose, review dashboard changes like code: a pull request, a screenshot in the description, and one reviewer who checks units, thresholds and that every new panel names its question. A quarterly review that deletes unviewed dashboards keeps the folder from turning back into wallpaper.
You will collapse three copied RED dashboards into one templated service dashboard, build a six-panel overview that links into it, export both, and load them back from disk.
1. One service dashboard instead of three. Open gateway RED, Save as service RED with UID service-red. In Settings → Variables add a Query variable named job, data source Prometheus, query:
label_values(http_server_request_duration_seconds_count, job)Then in each panel replace job="gateway" with job="$job". Add a fourth panel, Saturation. Every service exports an in-flight gauge on its own /metrics, which works per service:
sum(http_requests_in_flight{job="$job"})The host’s CPU pressure, from the node-exporter service you added in the RED chapter’s step 4, is the host-level alternative, and the overview below uses it:
rate(node_pressure_cpu_waiting_seconds_total[$__rate_interval])/gateway|orders|payments/). Switching it redraws all four panels for that service. The three copied dashboards are now redundant; delete them once the overview links here.2. Build the overview. New dashboard, title checkout overview, UID checkout-overview. Six panels, in this layout: a top row of three Stat panels (with sparklines), a middle row of two time series, and one at the bottom.
# 1 Stat "Gateway rate" (unit reqps)
sum(rate(http_server_request_duration_seconds_count{job="gateway"}[$__rate_interval]))
# 2 Stat "Gateway errors" (unit percentunit; thresholds green, red at 0.01)
sum(rate(http_server_request_duration_seconds_count{job="gateway", http_response_status_code=~"5.."}[$__rate_interval]))
/ sum(rate(http_server_request_duration_seconds_count{job="gateway"}[$__rate_interval]))
# 3 Stat "Gateway p99" (unit s; red at 0.5)
histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{job="gateway"}[$__rate_interval])))
# 4 Time series "Errors by service" (percentunit; legend {{job}})
sum by (job) (rate(http_server_request_duration_seconds_count{job=~"gateway|orders|payments", http_response_status_code=~"5.."}[$__rate_interval]))
/ sum by (job) (rate(http_server_request_duration_seconds_count{job=~"gateway|orders|payments"}[$__rate_interval]))
# 5 Time series "p99 by service" (s; legend {{job}})
histogram_quantile(0.99, sum by (job, le) (rate(http_server_request_duration_seconds_bucket{job=~"gateway|orders|payments"}[$__rate_interval])))
# 6 Time series "Saturation: CPU pressure" (percentunit)
rate(node_pressure_cpu_waiting_seconds_total[$__rate_interval])Give each panel a one-sentence description saying what to do when it is red. Panel 6 needs node-exporter from the RED chapter; panel 5 assumes you undid the previous chapter’s native-histogram step, so payments still has _bucket series.
3. Link the layers. On panels 4 and 5, open Data links and actions → Add link, title Open ${__field.labels.job} RED, URL:
/d/service-red/service-red?var-job=${__field.labels.job}&${__url_time_range}On the overview’s dashboard settings, Links → Add dashboard link of type Dashboards, tag use (and tag the host USE dashboard use), with Include current time range on. Now plant a fault:
cd labs/observability
FAULT_ERROR_RATE=0.05 docker compose --profile telemetry up -d payments(The .env from the OpenTelemetry chapter keeps the SDK and the semconv opt-in on for the recreated container.)
service RED with job=payments selected and the same time range. From there, the header link reaches the USE dashboard in one more click. Time from the overview to the right service dashboard: under ten seconds. Compare that with opening the three old dashboards in turn.4. Export the JSON. For each of the two dashboards: Export → Export as code, leave “Share dashboard with another instance” off, and copy the JSON. First see where your stack’s provider reads from (you are still in labs/observability):
grep -A3 'options' grafana/provisioning/dashboards/dashboards.yaml
grep -n 'dashboards' compose.yamlThe provider reads /var/lib/grafana/dashboards, which compose mounts from grafana/dashboards/. Save the two files there as grafana/dashboards/checkout-overview.json and grafana/dashboards/service-red.json. Check that each file starts with the right uid and has your variable:
jq '{uid, title, vars: [.templating.list[].name], panels: (.panels | length)}' grafana/dashboards/checkout-overview.json grafana/dashboards/service-red.json{"uid": "checkout-overview", "title": "checkout overview", "vars": [], "panels": 6} and {"uid": "service-red", "title": "service RED", "vars": ["job"], "panels": 4}. If the panel data sources read ${DS_PROMETHEUS} instead of a real uid, you exported with the share switch on; export again with it off, because file provisioning does not fill in those inputs.5. Reload and prove the files are the source. Delete both dashboards in the UI, then ask Grafana to re-read the provisioning directory:
curl -s -X POST -u admin:admin http://localhost:3000/api/admin/provisioning/dashboards/reload | jq
curl -s -u admin:admin 'http://localhost:3000/api/search?query=checkout' | jq '.[] | {uid, title}'{"message": "Dashboards config reloaded"}, then the overview listed again with uid checkout-overview. Opening it shows that the dashboard is provisioned; the lab’s provider sets allowUiUpdates: true, so you can still save from the UI, and the next file change overwrites what you saved, which is why production providers set it to false. The files are now the source of truth; git status shows them as new files ready to commit. Turn the fault off before you leave: docker compose --profile telemetry up -d payments.service-red.json and change the Errors panel’s filter from job="$job" to job=~"$job", then set the variable to Multi-value with Include All. Reload, select All, and look at the Errors panel: one line, the error ratio summed across all three services, which hides the fact that only payments is failing. Add by (job) to both halves of the ratio and reload: three lines again. A template variable that changes what a query aggregates is a correctness change, not a cosmetic one, and this is exactly the diff a reviewer should catch.Your company has 30 HTTP services, all instrumented with OTel, and about 200 hand-edited Grafana dashboards, many of them near-copies. You want every service to have the same RED and saturation layout, reviewed changes, and no drift. The platform team writes Go and Python; nobody uses Jsonnet today. What do you adopt?
- DOC Grafana dashboard best practices
USE and RED as dashboard strategies, the maturity model from ad hoc to generated dashboards, and the concrete habits: hierarchy, template variables, meaningful colour, links from alerts, version control. Read it all; it is short.
- BOOK Observability Engineering Charity Majors, Liz Fong-Jones, George Miranda, 2022
The counter-argument to dashboards as the main debugging tool: dashboards answer the questions you predicted, and debugging needs the ones you did not. Read it to know where dashboards stop. Read: chapter 8 on analysing events and chapter 9 on how observability and monitoring fit together.
- DOC Provisioning Grafana
The dashboard provider file (path, foldersFromFilesStructure, allowUiUpdates, updateIntervalSeconds) and how uid and id behave for provisioned dashboards. Skip the alerting and plugin sections.
- DOC Configure data links
Every variable a data link URL can use: field labels, series name, value time, the dashboard time range. This is the page you keep open while building drill-downs.
- DOC Prometheus template variables in Grafana
label_values, query_result and the exact definition of $__rate_interval, which explains why it beats a hard-coded rate window on any dashboard that gets zoomed.
- CODE Grafana Foundation SDK
Typed dashboard builders for Go, TypeScript, Python, PHP and Java, with examples. Read one example in your language and the section on building and exporting JSON.
- DOC Introduction to exemplars
What an exemplar is and how it appears on a panel, as the bridge from a latency spike to one real trace. The O3 tracing chapter builds on it.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.