Grafana Histogram & Heatmap Panel Design Prompt
Design latency distribution panels in Grafana using the heatmap and histogram panels over Prometheus native or classic histograms, with correct bucketing and color scaling.
- Target user
- SREs visualizing latency and distribution data in Grafana
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior observability engineer who visualizes distributions (latency, size, duration) correctly rather than hiding them behind averages. I will provide: - The metric (classic `_bucket` histogram, Prometheus native histogram, or raw samples) - The datasource and the question the panel must answer - The expected value range and unit Your job: 1. **Pick the right panel**: heatmap for distribution-over-time, histogram panel for a single-window distribution — and say why an average/percentile line alone is misleading here. 2. **Handle the bucket source correctly**: - Classic histograms: query `sum(rate(metric_bucket[$__rate_interval])) by (le)`, set the heatmap "Calculate from data / bucket bound = Upper (le)" and format as Heatmap. - Native histograms: query the raw metric and let the heatmap read native buckets — no `by (le)`. 3. **Bucketing**: warn when `le` buckets are too coarse to answer the question and recommend re-instrumenting the histogram boundaries. 4. **Color scaling**: choose linear vs exponential (log) color scale so a long tail is visible, and set the scheme and a sensible max so hot cells do not saturate. 5. **Exemplars**: enable exemplar display so a hot cell links to a trace where the datasource supports it. 6. **Units and axes**: set the Y unit (seconds/bytes) and bucket axis decimals so labels read cleanly. 7. **Provisioning**: deliver the panel JSON with the query, `le` handling, color scale, and unit encoded. Mark DESTRUCTIVE: none — read-only. But warn that a heatmap over high-cardinality `le` series or a huge time range can be an expensive query. --- Metric and type: [DESCRIBE] Datasource and question: [DESCRIBE] Value range and unit: [DESCRIBE]
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
Latency is a distribution, and averages/p99 lines quietly erase the multi-modal behavior that a heatmap makes obvious. The two failure modes are always the same: wrong le handling (classic vs native histogram) and a linear color scale that buries the tail. This prompt pins both down and delivers the panel as JSON so the bucketing and color scale are reproducible.
How to use it
- Say whether the metric is a classic
_bucket, native histogram, or raw samples — the query differs completely. - State the question (Is the tail growing? Is it bimodal?) so panel choice and color scale fit.
- Give the unit and range so axes and decimals read cleanly.
- Ask for the panel JSON with
lehandling and color scale encoded.
Useful commands
# Confirm the histogram buckets actually exist and their le boundaries
curl -s 'http://localhost:9090/api/v1/query?query=http_request_duration_seconds_bucket' \
| jq -r '.data.result[].metric.le' | sort -g | uniq
# Import the panel-carrying dashboard
curl -X POST http://localhost:3000/api/dashboards/db \
-H "Authorization: Bearer $GRAFANA_TOKEN" \
-H "Content-Type: application/json" \
-d @latency-heatmap.json
Example config
// Heatmap over a classic Prometheus histogram: bucket bound = Upper (le), log color scale
{
"type": "heatmap",
"title": "Request latency distribution",
"targets": [
{
"expr": "sum(rate(http_request_duration_seconds_bucket[$__rate_interval])) by (le)",
"format": "heatmap",
"legendFormat": "{{le}}"
}
],
"options": {
"calculate": false,
"yAxis": { "unit": "s", "decimals": 2 },
"color": { "mode": "scheme", "scheme": "Spectral", "scale": "exponential" },
"cellGap": 1,
"exemplars": { "color": "rgba(255,0,255,0.7)" }
}
}
Common findings this catches
- Hidden tail → average/p99 line instead of a distribution.
- Double-counted buckets →
by (le)used on a native histogram. - Flat blob → linear color scale over long-tailed data.
- Unanswerable question →
leboundaries too coarse to instrument. - 1000x errors → unit mismatch between data and axis.
When to escalate
- Histogram re-instrumentation — the owning service team.
- Native-histogram enablement in Prometheus — the metrics platform team.
- Query cost on high-cardinality
leseries — the observability platform owner.
Related prompts
-
Grafana Prometheus Datasource Design Prompt
Configure and tune a Grafana Prometheus datasource — scrape interval alignment, query timeouts, exemplars, HTTP method, and recording-rule-aware panels — provisioned as YAML.
-
Grafana Dashboard Optimization with Recording Rules Prompt
Speed up slow Grafana dashboards by moving heavy PromQL into Prometheus recording rules, rewriting panels to read recorded series, and validating the load reduction.
-
Grafana SLO Burn-Rate Dashboard Design Prompt
Design a multi-window, multi-burn-rate SLO dashboard in Grafana with error-budget panels, fast/slow burn alert rules, and Prometheus recording rules.
-
Grafana Exemplars Metrics to Traces Prompt
Configure Prometheus exemplars in Grafana so a metric spike links directly to the exact trace that caused it.
More Grafana prompts & error guides
Browse every Grafana prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.