increase() function
The increase()
function calculates the cumulative sum of non-negative differences between subsequent values. A main use case is tracking changes in counter values which may wrap over time when they hit a threshold or are reset. In the case of a wrap/reset, we can assume that the absolute delta between two points will be at least their non-negative difference.
*Function type: Transformation
**Output data type:* Float
increase(columns: ["_value"])
Parameters
columns
The columns to use in the operation. Defaults to ["_value"]
.
*Data type: Array of strings*
Output tables
For each input table with n
rows, derivative()
outputs a table with n - 1
rows.
Examples
from(bucket: "example-bucket")
|> range(start: -24h)
|> filter(fn: (r) =>
r._measurement == "system" and
r._field == "n_users"
)
|> increase()
Given the following input table:
_time | _value |
---|---|
00001 | 1 |
00002 | 5 |
00003 | 3 |
00004 | 4 |
increase()
produces the following table:
_time | _value |
---|---|
00002 | 4 |
00003 | 4 |
00004 | 5 |
Function definition
increase = (tables=<-, column="_value") =>
tables
|> difference(nonNegative: true, column:column)
|> cumulativeSum()