Skip to main content
In the previous lab we focused on time-series panels — the standard visualizations for Prometheus metrics. This lesson introduces additional visualizations: histograms and heatmaps. These let you visualize latency as a distribution instead of a single aggregated value, and show how that distribution evolves over time. Heatmaps are especially useful for spotting whether the entire request population is slowing down (e.g., 100% of requests shift) versus only a tail (e.g., the 95th percentile). Percentiles remain important for SLOs and alerting, but heatmaps preserve distribution + time for richer troubleshooting. Below are the deployment/provisioning steps used in this lesson followed by concrete guidance for adding histogram and heatmap panels in Grafana.

Deploy the demo application and provision the Grafana dashboard

  1. Run the app setup script to deploy the demo backend, frontend, and ServiceMonitors:
Representative console output (condensed):
  1. Apply the prebuilt Grafana dashboard ConfigMap (golden-signals):
Representative sidecar log confirming dashboard provisioning (condensed):
Provisioning dashboards via a ConfigMap + Grafana sidecar is an Infrastructure-as-Code pattern. It enables reproducible dashboards, version control, and automated dashboard deployments across environments.

Why use heatmaps instead of (or in addition to) histograms?

  • Histogram (single distribution): aggregates bucketed latencies across the entire time range and gives you one distribution snapshot (useful for percentiles and overall shape).
  • Heatmap (distribution over time): preserves the time dimension by rendering a histogram per time slice. Color indicates density, so you can see when the distribution shifts and how the tail behaves over time.
Quick comparison:

Create a backend latency histogram (single aggregated distribution)

  1. In Grafana, edit your dashboard → Add panel:
    • Title: Backend HTTP Latency Distribution
    • Visualization: Histogram (or keep time series and switch to Histogram)
    • Optionally hide the legend for a cleaner view.
  2. Example PromQL to produce a single percentile (P95) time-series derived from histogram buckets:
Notes:
  • histogram_quantile() computes the percentile from bucket counts.
  • The query above produces a single timeseries (p95) — not a histogram visualization itself.
  • Save the panel. This represents the distribution aggregated across the selected dashboard time range (e.g., last 15 minutes).
Limitations:
  • Aggregated histograms lose the per-time-slice evolution of the distribution. If you need to know when a shift happened, use a heatmap.

Create a backend latency heatmap (distribution over time)

  1. Add a new Grafana panel:
    • Title: Backend HTTP Latency Distribution Over Time
    • Visualization: Heatmap
    • Unit: milliseconds
    • Color scheme: Spectral (useful for clear density contrast)
    • In “Calculate from data” set to No so Grafana uses your histogram buckets directly
    • Tooltip: enable “Show histogram” and set tooltip Y-axis to show histogram
  2. Prometheus query — feed Grafana the bucket counts per time slice:
Why this query works:
  • Use the _bucket metric (the histogram bucket series).
  • increase(...[$__rate_interval]) returns the delta for each bucket during each Grafana interval; this produces per-time-slice counts.
  • sum by (le)(...) aggregates across all labels except le (the bucket boundary). Grafana expects bucketed series keyed by le.
  1. Configure heatmap options:
    • Format: Heatmap
    • Color scheme: Spectral (or any perceptually uniform palette)
    • Tooltip: Show histogram, set Y-axis to histogram
    • Save the dashboard.
A dark-themed Grafana dashboard displaying order-processing metrics, with multiple charts and histograms showing HTTP latency distribution (p50/p95/p99) and time-series latency spikes. The panels include legends for endpoints like /api/orders and /health and controls for time range and refresh.

Heatmap color selection — why Spectral helps

A multi-color palette (Spectral) makes density differences easy to spot: high-density areas appear red while low-density areas stay blue. That contrast helps you quickly identify when requests concentrate in higher-latency buckets.

Hover histogram behavior

By enabling “Show histogram” in the tooltip and setting the tooltip Y-axis to histogram, Grafana surfaces the full bucket counts for the selected time column. This gives you both the time-series context and the exact distribution for that instant. Correct heatmap query (repeated for clarity):

Use the order-processing UI to observe distribution changes

While the heatmap is visible, change the demo application’s load and processing latency settings to see how the heatmap reacts. Typical controls include:
  • Traffic level (low / medium / high)
  • Average processing latency (fast / slower)
  • Simulated error rate
When you reduce processing latency (for example, switching the demo from “slower” to “faster”), you should see:
  • High-density regions shift from higher-latency buckets to lower-latency buckets over time.
  • The tail (higher buckets) shrinks as queued requests complete.
  • The heatmap reveals the exact times when the distribution moved.
A screenshot of an "Order Processing Dashboard" web interface showing controls for Async Request Rate, Average Processing Latency, and Simulated Error Rate with radio buttons selected. The page also includes a "Process Order Manually" button and metric panels (total orders, successful, failed, avg latency).
Which panel identifies the exact change?
  • The aggregated histogram shows the overall distribution but not when a change occurred.
  • The heatmap preserves distribution per time slice and is therefore best for identifying the exact timestamp when latency began to decrease. Hover any column to inspect the histogram for that moment.
When using increase(...[$__rate_interval]), ensure your Grafana dashboard interval aligns with your scrape interval and the cardinality of bucket series. Very long intervals or mismatched scrape configs can produce misleading deltas. Test queries in Prometheus/Explore first if results look unexpected.

Summary & best practices

  • Histograms give you a single aggregated distribution across the selected time window; use them for percentiles (p50/p95/p99).
  • Heatmaps add time to the distribution, letting you see how latency buckets change over time.
  • For Prometheus + Grafana heatmaps:
    • Use the _bucket metric.
    • Feed Grafana per-interval counts with increase(...[$__rate_interval]).
    • Aggregate with sum by (le)(...) so only the le bucket label remains.
  • Choose a perceptually clear color map (Spectral or similar) to highlight density differences.
  • Provision dashboards using ConfigMaps + Grafana sidecar for reproducible, version-controlled dashboards.
If you want, I can provide a copy‑paste-ready JSON panel snippet you can add to your golden-signals ConfigMap to provision the heatmap automatically.

Watch Video