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
-
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.
-
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).
-
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.Default value
: only available ifEvaluate Insufficient Data
is enabled. The default value will be used if there is no data for the input measurement.
-
Evaluate Insufficient Data
- If enabled the script will run regardless of the availability of data for the input measurements.
- If disabled the script will not be run on points where there are one or more values missing for the input measurements. The calculation will write an error point with status `BadInsufficientData'
-
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 thevalue
field - a
string
input measurement -> uses thevalue_str
field - a
boolean
input measurement -> uses thevalue_bool
field - an
array
input measurement -> uses thevalue
field (which records the length of the array)
count
Returns the number of non-null fields values.
integral
Returns the area under the curve for subsequent field values.
mean
Returns the arithmetic mean (average) of field values.
median
Returns the middle value from a sorted list of field values.
mode
Returns the most frequent value in a list of field values.
spread
Returns the difference between the minimum and maximum field values.
stddev
Returns the standard deviation of field values.
sum
Returns the sum of field values.
first
Returns the field value with the oldest timestamp.
last
Returns the field value with the most recent timestamp.
max
Returns the greatest field value.
min
Returns the lowest field value.
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.