1.9 KiB
1.9 KiB
title | description | aliases | menu | weight | related | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
increase() function | The `increase()` function calculates the cumulative sum of **non-negative** differences between subsequent values. |
|
|
402 |
|
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()
{{< flex >}} {{% flex-content %}} Given the following input table:
_time | _value |
---|---|
00001 | 1 |
00002 | 5 |
00003 | 3 |
00004 | 4 |
{{% /flex-content %}} | |
{{% flex-content %}} | |
increase() produces the following table: |
_time | _value |
---|---|
00002 | 4 |
00003 | 4 |
00004 | 5 |
{{% /flex-content %}} | |
{{< /flex >}} |
Function definition
increase = (tables=<-, column="_value") =>
tables
|> difference(nonNegative: true, column:column)
|> cumulativeSum()