PCA practice question 9 of 15

Which metric type uses the delta() function?

Full set: 60 questions
Answer options
A: Info
B: Histogram
C: Gauge Correct answer
D: Counter
Correct Answer:
C. Gauge
Explanation

The delta() function in PromQL calculates the difference between the first and last value of each time series in a specified time range. This function is specifically designed for the Gauge metric type, which represents a numerical value that can arbitrarily go up and down, such as temperature or current memory usage. For example, delta(cputempcelsius[2h]) calculates how much the CPU temperature has changed over the last two hours. For Counter metrics, which only increase, the increase() function is the appropriate choice as it correctly handles counter resets.

Why Incorrect

A. Info: This is a synthetic metric type used to expose textual information; it is not a numerical time series and cannot be used with delta().
B. Histogram: This is a complex type for observing distributions. Its underlying components (sum, bucket) are counters, for which increase() is the correct function.
D. Counter: The increase() function should be used for counters as it is designed to handle resets gracefully, whereas delta() is not.

References

1. Prometheus Authors. (n.d.). Querying functions. Prometheus Documentation. Retrieved from https://prometheus.io/docs/prometheus/latest/querying/functions/#delta

Reference detail: The documentation explicitly states, "delta should only be used with gauges."

2. Prometheus Authors. (n.d.). Metric types. Prometheus Documentation. Retrieved from https://prometheus.io/docs/concepts/metrictypes/

Reference detail: This page defines the four metric types. It describes a Gauge as a value that "can arbitrarily go up and down," which aligns with the use case for delta(). It also specifies that for Counters, one should "use rate() to calculate the per-second average rate of increase," and by extension, increase() for the total increase.

Scroll to Top