趋势存储每小时的聚合值。趋势函数利用这些每小时平均值,因此对于 长期分析非常有用。
趋势函数的结果被缓存,因此对相同函数和相同参数的多次调用 仅从数据库获取一次信息。趋势函数缓存由 TrendFunctionCacheSize服务器参数控制。
仅引用趋势函数的触发器仅在表达式中最小时间周期内评估一次。 例如,像这样的触发器
将每天评估一次。如果触发器同时包含趋势和历史(或日期和时间和/或nodata()函数), 则根据常规原则进行计算。
这里列出的所有函数都支持:
函数列表中没有附加信息。点击函数以查看完整详情。
函数 | 描述 |
---|---|
baselinedev | 返回最后一个数据周期与前几季(由stddevpop算法)相同数据周期之间的偏差数。 |
baselinewma | 通过使用加权移动平均算法,从多个相等时间周期('季节')的同一时间框架中平均数据来计算基线。 |
trendavg | 在定义的时间段内趋势值的平均值。 |
trendcount | 在定义的时间段内用于计算趋势值的成功检索的历史值的数量。 |
trendmax | 在定义的时间段内趋势值的最大值。 |
trendmin | 在定义的时间段内趋势值的最小值。 |
trendstl | 返回检测周期中异常的比率 - 一个介于0和1之间的十进制值,即((异常值的数量)/(总值的数量)) 。 |
trendsum | 在定义的时间段内趋势值的总和。 |
/host/key
是常见的强制第一个参数time period:time shift
是常用的第二个参数,其中:
N
- 时间单位数,time unit
- h(小时) , d(日),w(周),M(月)或 y(年)。关于函数参数的一般性说明:
<
>
表示/host/key
和(sec|#num)<:time shift>
参数绝对不能加引号返回上一个数据周期与前一时间段中相同数据周期之间的偏差数(通过stddevpop算法)。
参数:
N
- 时间单位数time unit
- h(小时) , d(日),w(周),M(月)或 y(年),必须等于或者小于时间周期示例:
baselinedev(/host/key,1d:now/d,"M",6) #calculating the number of standard deviations (population) between the previous day and the same day in the previous 6 months. If the date doesn't exist in a previous month, the last day of the month will be used (Jul,31 will be analysed against Jan,31, Feb, 28,... June, 30)
baselinedev(/host/key,1h:now/h,"d",10) #calculating the number of standard deviations (population) between the previous hour and the same hours over the period of ten days before yesterday
使用加权移动平均算法通过对多个相等时间段(‘seasons’)中的相同时间范围内的数据进行平均来计算基线。
参数:
N
- 时间单位数time unit
- h(小时) , d(日),w(周),M(月)或 y(年),必须等于或者小于时间周期示例:
baselinewma(/host/key,1h:now/h,"d",3) #calculating the baseline based on the last full hour within a 3-day period that ended yesterday. If "now" is Monday 13:30, the data for 12:00-12:59 on Friday, Saturday, and Sunday will be analyzed
baselinewma(/host/key,2h:now/h,"d",3) #calculating the baseline based on the last two hours within a 3-day period that ended yesterday. If "now" is Monday 13:30, the data for 11:00-12:59 on Friday, Saturday, and Sunday will be analyzed
baselinewma(/host/key,1d:now/d,"M",4) #calculating the baseline based on the same day of month as 'yesterday' in the 4 months preceding the last full month. If the required date doesn't exist, the last day of month is taken. If today is September 1st, the data for July 31st, June 30th, May 31st, April 30th will be analyzed.
在定义的时间段内趋势值的平均值。
参数:
示例:
trendavg(/host/key,1h:now/h) #the average for the previous hour (e.g. 12:00-13:00)
trendavg(/host/key,1h:now/h-1h) #the average for two hours ago (11:00-12:00)
trendavg(/host/key,1h:now/h-2h) #the average for three hours ago (10:00-11:00)
trendavg(/host/key,1M:now/M-1y) #the average for the previous month a year ago
在定义的时间段内用于计算趋势值的成功检索到的历史值的数量。
参数:
示例:
trendcount(/host/key,1h:now/h) # 上一小时的值数量(例如 12:00 - 13:00)
trendcount(/host/key,1h:now/h - 1h) # 两小时前的值数量(11:00 - 12:00)
trendcount(/host/key,1h:now/h - 2h) # 三小时前的值数量(10:00 - 11:00)
trendcount(/host/key,1M:now/M - 1y) # 一年前的上一个月的值数量
在定义的时间段内趋势值的最大值。
参数:
示例:
trendmax(/host/key,1h:now/h) #the maximum for the previous hour (e.g. 12:00-13:00)
trendmax(/host/key,1h:now/h) - trendmin(/host/key,1h:now/h) → calculate the difference between the maximum and minimum values (trend delta) for the previous hour (12:00-13:00)
trendmax(/host/key,1h:now/h-1h) #the maximum for two hours ago (11:00-12:00)
trendmax(/host/key,1h:now/h-2h) #the maximum for three hours ago (10:00-11:00)
trendmax(/host/key,1M:now/M-1y) #the maximum for the previous month a year ago
在定义的时间段内趋势值的最小值。
参数:
示例:
trendmin(/host/key,1h:now/h) #the minimum for the previous hour (e.g. 12:00-13:00)
trendmax(/host/key,1h:now/h) - trendmin(/host/key,1h:now/h) → calculate the difference between the maximum and minimum values (trend delta) for the previous hour (12:00-13:00)
trendmin(/host/key,1h:now/h-1h) #the minimum for two hours ago (11:00-12:00)
trendmin(/host/key,1h:now/h-2h) #the minimum for three hours ago (10:00-11:00)
trendmin(/host/key,1M:now/M-1y) #the minimum for the previous month a year ago
返回检测期间的异常率 - 一个介于 0 和 1 之间的十进制值,即((异常值的数量)/(值的总数))
。
参数:
N
- 时间单位数time unit
- h(小时) , d(日),w(周),M(月)或 y(年)N
- 时间单位数time unit
- h(小时) , d(日),w(周)N
- 时间单位数time unit
- h(小时) , d(日),w(周)示例:
trendstl(/host/key,100h:now/h,10h,2h) #analyse the last 100 hours of trend data, find the anomaly rate for the last 10 hours of that period, expecting the periodicity to be 2h, the remainder series values of the evaluation period are considered anomalies if they reach the value of 3 deviations of the MAD of that remainder series
trendstl(/host/key,100h:now/h-10h,100h,2h,2.1,"mad") #analyse the period of 100 hours of trend data, up to 10 hours ago, find the anomaly rate for that entire period expecting the periodicity to be 2h, the remainder series values of the evaluation period are considered anomalies if they reach the value of 2,1 deviations of the MAD of that remainder series
trendstl(/host/key,100d:now/d-1d,10d,1d,4,,10) #analyse 100 days of trend data up to a day ago, find the anomaly rate for the period of last 10d of that period, expecting the periodicity to be 1d, the remainder series values of the evaluation period are considered anomalies if they reach the value of 4 deviations of the MAD of that remainder series, overriding the default span of the loess window for seasonal extraction of "10 * number of entries in eval period + 1" with the span of 10 lags
trendstl(/host/key,1M:now/M-1y,1d,2h,,"stddevsamp") #analyse the previous month a year ago, find the anomaly rate of the last day of that period expecting the periodicity to be 2h, the remainder series values of the evaluation period are considered anomalies if they reach the value of 3 deviation of the sample standard deviation of that remainder series
在定义的时间段内趋势值的总和。
参数:
示例:
trendsum(/host/key,1h:now/h) #the sum for the previous hour (e.g. 12:00-13:00)
trendsum(/host/key,1h:now/h-1h) #the sum for two hours ago (11:00-12:00)
trendsum(/host/key,1h:now/h-2h) #the sum for three hours ago (10:00-11:00)
trendsum(/host/key,1M:now/M-1y) #the sum for the previous month a year ago
参见 所有支持的函数。