3.5 KiB
title | description | aliases | menu | weight | flux/v0.x/tags | related | introduced | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
integral() function | The `integral()` function computes the area under the curve per unit of time of subsequent non-null records. |
|
|
102 |
|
|
0.7.0 |
The integral()
function computes the area under the curve per unit
of time of subsequent non-null records.
integral()
requires _start
and _stop
columns that are part of the group key.
The curve is defined using _time
as the domain and record values as the range.
integral()
is an aggregate function.
Output data type: Float
integral(
unit: 10s,
column: "_value",
timeColumn: "_time",
interpolate: "",
)
Parameters
unit
({{< req >}}) Time duration used when computing the integral.
column
Column on which to operate.
Defaults to "_value"
.
timeColumn
Column that contains time values to use in the operation.
Defaults to "_time"
.
interpolate
Type of interpolation to use.
Defaults to ""
.
Use one of the following interpolation options:
- empty string for no interpolation
- linear
tables
Input data.
Default is piped-forward data (<-
).
Examples
{{% flux/sample-example-intro plural=true %}}
Calculate the integral
import "sampledata"
sampledata.int()
|> range(start: sampledata.start, stop: sampledata.stop)
|> integral(unit:10s)
{{< expand-wrapper >}} {{% expand "View input and output" %}}
Input data
{{% flux/sample set="int" includeRange=true %}}
Output data
_start | _stop | tag | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 50.0 |
_start | _stop | tag | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 43 |
{{% /expand %}} {{< /expand-wrapper >}}
Calculate the integral with linear interpolation
import "sampledata"
sampledata.int(includeNull: true)
|> range(start: sampledata.start, stop: sampledata.stop)
|> integral(unit:10s, interpolate: "linear")
{{% expand "View input and output" %}}
Input data
{{% flux/sample set="int" includeNull=true includeRange=true %}}
Output data
_start | _stop | tag | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 25.0 |
_start | _stop | tag | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 32.5 |
{{% /expand %}}