1 聚合函数

除非另有说明,此处列出的所有功能均受支持:

聚合函数可以使用:

  • 监控项历史数据, 例如, min(/host/key,1h)
  • 预测函数 作为 唯一的参数,例如, min(last_foreach(/*/key))

关于函数参数的一些一般说明:

  • 函数参数用逗号分隔
  • 可选函数参数(或参数部分)由 < >
  • 每个函数都描述了函数特定的参数
  • /host/key(sec|#num)<:time shift> 参数绝不能引用
常用参数
  • /host/key是函数的常见强制性第一个参数 引用主机监控项历史
  • (sec|#num)<:time shift> 是常见的第二个参数 引用主机监控项历史的函数,其中
    • sec - 最大评估周期 in seconds(时间 时间戳后缀 可以使用), or
    • #num - 最大次数 评估范围最新 收集的值(如果前面有#号)
    • time shift(可选)允许移动评估点历史点。关于指定时移更多细节查看。

Function details

Some general notes on function parameters:

  • Function parameters are separated by a comma
  • Optional function parameters (or parameter parts) are indicated by < >
  • Function-specific parameters are described with each function
  • /host/key and (sec|#num)<:time shift> parameters must never be quoted
avg(/host/key,(sec|#num)<:time shift>)

The average value of an item within the defined evaluation period.
Supported value types: Float, Integer.

Parameters: see common parameters.

Time shift is useful when there is a need to compare the current average value with the average value some time ago.

Examples:

  1. avg(/host/key,1h) #the average value for the last hour until now
  2. avg(/host/key,1h:now-1d) #the average value for an hour from 25 hours ago to 24 hours ago from now
  3. avg(/host/key,#5) #the average value of the five latest values
  4. avg(/host/key,#5:now-1d) #the average value of the five latest values excluding the values received in the last 24 hours
bucket_percentile(item filter,time period,percentage)

Calculates the percentile from the buckets of a histogram.

Parameters:

Comments:

  • Supported only in calculated items;
  • This function is an alias for histogram_quantile(percentage/100, bucket_rate_foreach(item filter, time period, 1)).
count(func_foreach(item filter,<time period>))

The count of values in an array returned by a foreach function.
Supported value type: Integer.

Parameters:

  • func_foreach - foreach function for which the number of returned values should be counted (with supported arguments). See foreach functions for details.
  • item filter - see item filter;

  • time period - see time period.

Using count() with a history-related foreach function (max_foreach, avg_foreach, etc.) may lead to performance implications, whereas using exists_foreach(), which works only with configuration data, will not have such effect.

Examples:

  1. count(max_foreach(/*/net.if.in[*],1h)) #the number of net.if.in items that received data in the last hour until now
histogram_quantile(quantile,bucket1,value1,bucket2,value2,…)

Calculates the φ-quantile from the buckets of a histogram.

Parameters:

  • quantile - 0 ≤ φ ≤ 1;

  • bucketN, valueN - manually entered pairs (>=2) of parameters or the response of bucket_rate_foreach.

Comments:

  • Supported only in calculated items;
  • Functionally corresponds to ‘histogram_quantile‘ of PromQL;
  • Returns -1 if values of the last ‘Infinity’ bucket (“+inf”) are equal to 0.

Examples:

  1. histogram_quantile(0.75,1.0,last(/host/rate_bucket[1.0]),"+Inf",last(/host/rate_bucket[Inf]))
  2. histogram_quantile(0.5,bucket_rate_foreach(//item_key,30s))
item.count(item filter)

The count of existing items in configuration that match the filter criteria.
Supported value type: Integer.

Parameter:

  • item filter - criteria for item selection, allows referencing by host group, host, item key, and tags. Wildcards are supported. See item filter for more details.

Comments:

  • Supported only in calculated items;
  • Works as an alias for the count(exists_foreach(item_filter)) function.

Examples:

  1. item_count(/*/agent.ping?[group="Host group 1"]) #the number of hosts with the *agent.ping* item in the "Host group 1"
kurtosis(/host/key,(sec|#num)<:time shift>)

The “tailedness” of the probability distribution in collected values within the defined evaluation period. See also: Kurtosis.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. kurtosis(/host/key,1h) #kurtosis for the last hour until now
mad(/host/key,(sec|#num)<:time shift>)

The median absolute deviation in collected values within the defined evaluation period. See also: Median absolute deviation.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. mad(/host/key,1h) #median absolute deviation for the last hour until now
max(/host/key,(sec|#num)<:time shift>)

The highest value of an item within the defined evaluation period.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. max(/host/key,1h) - min(/host/key,1h) #calculate the difference between the maximum and minimum values within the last hour until now (the delta of values)
min(/host/key,(sec|#num)<:time shift>)

The lowest value of an item within the defined evaluation period.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. max(/host/key,1h) - min(/host/key,1h) #calculate the difference between the maximum and minimum values within the last hour until now (the delta of values)
skewness(/host/key,(sec|#num)<:time shift>)

The asymmetry of the probability distribution in collected values within the defined evaluation period. See also: Skewness.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. skewness(/host/key,1h) #the skewness for the last hour until now
stddevpop(/host/key,(sec|#num)<:time shift>)

The population standard deviation in collected values within the defined evaluation period. See also: Standard deviation.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. stddevpop(/host/key,1h) #the population standard deviation for the last hour until now
stddevsamp(/host/key,(sec|#num)<:time shift>)

The sample standard deviation in collected values within the defined evaluation period. See also: Standard deviation.
Supported value types: Float, Integer.

Parameters: see common parameters.

At least two data values are required for this function to work.

Example:

  1. stddevsamp(/host/key,1h) #the sample standard deviation for the last hour until now
sum(/host/key,(sec|#num)<:time shift>)

The sum of collected values within the defined evaluation period.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. sum(/host/key,1h) #the sum of values for the last hour until [now
sumofsquares(/host/key,(sec|#num)<:time shift>)

The sum of squares in collected values within the defined evaluation period.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. sumofsquares(/host/key,1h) #the sum of squares for the last hour until [now
varpop(/host/key,(sec|#num)<:time shift>)

The population variance of collected values within the defined evaluation period. See also: Variance.
Supported value types: Float, Integer.

Parameters: see common parameters.

Example:

  1. varpop(/host/key,1h) #the population variance for the last hour until now
varsamp(/host/key,(sec|#num)<:time shift>)

The sample variance of collected values within the defined evaluation period. See also: Variance.
Supported value types: Float, Integer.

Parameters: see common parameters.

At least two data values are required for this function to work.

Example:

  1. varsamp(/host/key,1h) #the sample variance for the last hour until now

See all supported functions.