Skip to content

integral

Input Stack:
expr: TimeSeriesExpr
Output Stack:
TimeSeriesExpr

Compute the running cumulative sum (integral) of a time series across the evaluation time window. Each output datapoint represents the total accumulated value from the start of the time range to that point. This is useful for calculating totals from rate data or estimating the area under a curve.

Parameters

  • expr: The time series expression to compute the integral of

Behavior

  • Each output value is the cumulative sum: integral[i] = sum(input[0] to input[i])
  • Missing values (NaN) are treated as zeros
  • Negative values will decrease the cumulative total
  • The result represents the area under the input curve

Data Processing

Input :integral
0 0
1 1
-1 0
NaN 0
0 0
1 1
2 3
1 4
1 5
0 5

Examples

Basic integral of a constant:

BeforeAfter
1
1,:integral

Integrating rate data to get total counts:

BeforeAfter
name,requestsPerSecond,:eq,
:sum,
:per-step
name,requestsPerSecond,:eq,
:sum,
:per-step,
:integral

Counter Metrics

For counter metrics, datapoints represent average rates per second. To get meaningful totals, first convert to per-step values using :per-step, then apply :integral to get the cumulative count.

  • :derivative - Rate of change (inverse operation)
  • :per-step - Convert rates for use with integral
  • :add - Single-step addition vs. cumulative sum
  • :rolling-sum - Rolling accumulation (related to cumulative operations)