A sampled calculation uses aggregated values of one or more measurements as input and runs the calculation script to output a single value for each time interval processed.

Sampled calculation settings

  1. Time interval

    • The time interval at which the calculation script is run and thus outputs a value.
    • For a seconds level time interval, the seconds fraction of the timestamp of a result will be a multiple of the time interval. For example a time interval of 5 seconds will result in a timestamp with a seconds fraction being a multiple of 5 seconds starting from 0 seconds (0, 5, 10, .. seconds).
    • The time interval is the same for all input measurements given.
  2. Interval offset

    • A seconds level offset is added to each minute before multiples of the time interval are taken into account. For example a time offset of 2 seconds, will result in a timestamp with a seconds fraction not starting from 0 seconds but from 2 seconds for each minute (2, 7, 12, .. seconds).
  3. Input measurement(s)

    • Alias: similar as the Raw calculation input measurement alias.
    • Measurement(s): similar as the Raw calculation input measurement. Although for a sampled calculation, multiple input measurements can be given, causing an output value to be solely calculated once there is new data available for all input measurements in the next time interval.
    • Aggregation type: at each time interval, an aggregated value is retrieved from an input measurement according to the aggregation type. The aggregation type may differ between multiple input measurements.
  4. Script

    • The script outputs a new value starting from the aggregated values of the input measurement(s).
    • Read further about setting up a calculation script .

Aggregation types

An overview of the possible aggregation types is listed below. Note that, depending on the datatype of the according input measurement, the aggregated value will be retrieved from a different field of the measurement. For more information about the time series data fields, checkout the influx storage model .

  • a number input measurement -> uses the value field
  • a string input measurement -> uses the value_str field
  • a boolean input measurement -> uses the value_bool field
  • an array input measurement -> uses the value field (which records the length of the array)
An input measurement having an array datatype returns an aggregated value of the array length.

count

Returns the number of non-null fields values.

More information

integral

Returns the area under the curve for subsequent field values.

More information

mean

Returns the arithmetic mean (average) of field values.

More information

median

Returns the middle value from a sorted list of field values.

More information

mode

Returns the most frequent value in a list of field values.

More information

spread

Returns the difference between the minimum and maximum field values.

More information

stddev

Returns the standard deviation of field values.

More information

sum

Returns the sum of field values.

More information

first

Returns the field value with the oldest timestamp.

More information

last

Returns the field value with the most recent timestamp.

More information

max

Returns the greatest field value.

More information

min

Returns the lowest field value.

More information

Performance

Picking a shorter time interval for a sampled calculation will cause a calculation to be triggered more frequently and thus increase the load on the active machine.

A script execution times out, if it does not complete in 10 seconds.