Course contentsShow
← Cloud and Infrastructure
Lesson 1969 of 2,98942. Observability - MetricsFree lesson

Gauge Functions and Changes

Query gauge metrics using delta(), increase(), and changes() to analyze absolute values over time.

Gauge Functions and Changes

You'll learn how to query gauge metrics using delta(), increase(), and changes() to analyze how absolute values fluctuate over time.

Understanding Gauge Queries

Unlike counters that only go up, gauges represent current measurements—like temperature, memory usage, or active connections. They rise and fall. To understand gauge behavior, you need functions that track these fluctuations.

Core Gauge Functions

delta()

Calculates the difference between the first and last value in a time range. Perfect for "how much did this change?"

delta(node_memory_available_bytes[5m])

This shows how much available memory increased or decreased over 5 minutes—positive for gains, negative for losses.

increase()

Technically designed for counters, but works on gauges too. It extrapolates the total increase, adjusting for rate. Use delta() instead for gauges—it's more semantically correct.

changes()

Counts how many times a gauge's value changed (not by how much) in the range.

changes(container_cpu_usage_seconds_total[10m])

This tells you if a gauge is volatile (many changes) or stable (few changes), useful for detecting flapping or instability.

When to Use Each

  • delta(): "My disk space dropped by 2GB in the last hour"
  • changes(): "This service's connection count changed 47 times in 10 minutes—something's wrong"

Analogy: Imagine tracking room temperature. delta() tells you "it dropped 5 degrees," while changes() tells you "the thermostat adjusted 12 times"—one measures magnitude, the other frequency.

Key Takeaway: Use delta() to measure how much a gauge changed over time, and changes() to detect volatility or instability in gauge metrics.