docs-v2/content/v2.0/reference/flux/stdlib/built-in/transformations/increase.md

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.
/v2.0/reference/flux/functions/transformations/aggregates/increase
/v2.0/reference/flux/functions/built-in/transformations/aggregates/increase/
/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase/
v2_0_ref
name parent
increase built-in-transformations
402
/v2.0/query-data/flux/increase/

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()