Skip to main content

Heatmaps

Introduction

Heatmaps are powerful visualizations that display data density across two dimensions using color intensity. In Grafana, heatmaps are particularly useful for visualizing the distribution of data points over time and value ranges, making them ideal for identifying patterns, anomalies, and trends in large datasets.

Unlike traditional line or bar charts that might hide density information, heatmaps reveal:

  • Where your data points are concentrated
  • How distributions change over time
  • Outliers and unusual patterns in your dataset
  • System behavior across different value ranges

Understanding Heatmaps

A heatmap organizes data into buckets along two axes:

  • X-axis (typically time)
  • Y-axis (values or categories)

Each cell or "bucket" is colored based on the number of data points falling within that specific range. The color intensity represents the density or count of observations in that bucket:

  • Darker/more intense colors = Higher count or density
  • Lighter colors = Lower count or density

This visualization is particularly valuable when you have too many individual data points to display clearly on a scatter plot.

When to Use Heatmaps

Heatmaps excel in these scenarios:

  • Distribution analysis: Understanding how values are distributed across a range
  • System performance monitoring: Tracking response times, resource utilization patterns
  • Anomaly detection: Spotting unusual patterns in data
  • High-cardinality data: Visualizing data with many unique values
  • Time-series analysis: Observing how distributions change over time

Creating a Heatmap in Grafana

Basic Setup

To create a heatmap visualization in Grafana:

  1. Create a new dashboard or edit an existing one
  2. Add a new panel
  3. Configure your data source query
  4. Select "Heatmap" from the visualization options

Data Requirements

For a functional heatmap, your data typically needs:

  • A time series (for the X-axis)
  • Numeric values to distribute along the Y-axis
  • Sufficient data points to show meaningful patterns

Configuration Options

Let's explore the key configuration options:

1. Data Format

Grafana can create heatmaps from:

  • Time series buckets: Pre-bucketed data where each series represents a y-axis bucket
  • Time series: Raw time series that Grafana will automatically bucket
  • Raw data: Non-time series data that you want to visualize as a heatmap

2. Bucket Configuration

Bucket size = (max value - min value) / number of buckets

Properly configured buckets are crucial for meaningful heatmaps. Options include:

  • Y-axis buckets: How many divisions to create on the value axis
  • Y-axis bucket bounds: How to calculate bucket boundaries (linear, logarithmic, etc.)
  • X-axis buckets: Time interval for grouping data points

3. Color Scheme

Color is the primary visual encoding in heatmaps. Grafana offers several options:

  • Color mode: Spectrum or opacity
  • Color scheme: Various palettes optimized for different data types
  • Scale: Linear or logarithmic scale for color mapping
  • Min/max values: Thresholds for color scaling

Practical Example: Server Response Time Distribution

Let's create a heatmap to visualize web server response times throughout the day.

Example Query (Prometheus)

sql
histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))

This query:

  1. Collects HTTP request durations
  2. Groups them into buckets
  3. Calculates rates over 5-minute windows
  4. Computes the 95th percentile

Visualization Configuration

For this example, we'll use these settings:

  1. Format: Time series buckets
  2. Y-axis buckets: 15 (divides response times into 15 ranges)
  3. Color scheme: Spectrum, from blue (low density) to red (high density)
  4. Tooltip: Show count and value range

Interpreting the Results

In the resulting heatmap:

  • X-axis shows time of day
  • Y-axis shows response time ranges (in milliseconds)
  • Color intensity indicates how many requests fall into each response time range

This visualization might reveal:

  • Response time patterns during peak hours
  • Unusual latency spikes
  • The most common response time ranges
  • How response distributions change throughout the day

Advanced Techniques

1. Using Annotations

Add annotations to mark significant events that might explain patterns in your heatmap:

Deployment → Response time shift
Server restart → Temporary gap in data
Config change → Distribution pattern change

2. Multiple Data Series

Compare multiple heatmaps by:

  • Creating multiple panels with different data sources
  • Using panel repeating to show heatmaps for different servers/services
  • Creating a dashboard variable to switch between different data sources

3. Custom Color Schemes

Customize color schemes for specific needs:

  • Red-yellow-green for SLA monitoring
  • Blue-purple for temperature data
  • Custom thresholds for your specific application's requirements

Common Challenges and Solutions

1. Too Many or Too Few Buckets

Problem: Heatmap appears too granular or too coarse.

Solution: Adjust the number of Y-axis buckets or the bucket size.

Too few buckets → Increase Y buckets
Too many buckets → Decrease Y buckets

2. Color Scale Not Showing Variation

Problem: Heatmap appears all one color or lacks contrast.

Solution: Adjust the color scale min/max values or switch to a logarithmic scale.

3. Sparse Data

Problem: Heatmap has many empty cells.

Solution: Increase the time range, reduce the number of buckets, or use a larger aggregation interval.

Real-World Applications

System Monitoring

Heatmaps are excellent for monitoring system metrics:

  • CPU utilization distribution across a cluster
  • Memory usage patterns
  • Disk I/O response times
  • Network packet size distributions

Example heatmap query for CPU usage:

sql
histogram_quantile(0.95, sum(rate(node_cpu_seconds_total{mode!="idle"}[1m])) by (instance, le))

User Behavior Analysis

Track user experience metrics:

  • Page load time distributions
  • User session duration patterns
  • Activity distribution by time of day
  • Feature usage frequency

IoT Sensor Data

Visualize patterns in sensor data:

  • Temperature distributions across locations
  • Vibration frequency analysis
  • Signal strength heatmaps
  • Environmental condition monitoring

Summary

Heatmaps provide a powerful way to visualize complex datasets in Grafana by:

  • Revealing distributions that might be hidden in other visualizations
  • Showing how patterns change over time
  • Identifying outliers and anomalies
  • Compressing large datasets into meaningful visual patterns

When properly configured, heatmaps can transform overwhelming quantities of data points into clear, actionable insights that help you:

  • Detect issues before they become critical
  • Understand normal operating patterns
  • Identify optimization opportunities
  • Communicate complex data patterns to stakeholders

Additional Resources

To further your understanding of heatmaps in Grafana:

  • Explore the official Grafana documentation for detailed configuration options
  • Practice creating heatmaps with different data sources and configurations
  • Experiment with combining heatmaps with other visualizations for comprehensive dashboards

Exercises

  1. Create a heatmap showing CPU usage across different servers over time
  2. Build a heatmap that visualizes HTTP response codes distribution by hour of day
  3. Configure a heatmap with custom color thresholds for SLA monitoring
  4. Design a dashboard that combines a heatmap with related line graphs for contextual analysis
  5. Create a heatmap showing the distribution of API request payload sizes

Remember that effective heatmaps require thoughtful configuration – experiment with different bucket sizes, color schemes, and data ranges to find the most informative visualization for your specific data.



If you spot any mistakes on this website, please let me know at [email protected]. I’d greatly appreciate your feedback! :)