InfuxDB函数说明

1. 聚合函数

1.1 COUNT()

描述:返回单个字段中非空(non-null)值的数量
语法

SELECT COUNT(<field_key>) FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

例子:

  • 计算字段water_level非空值的数量
> SELECT COUNT("water_level") FROM "h2o_feet"
name: h2o_feet
--------------
time                           count
1970-01-01T00:00:00Z     15258
  • 计算字段water_level非空值的数量,按时间间隔分组
> SELECT COUNT("water_level") FROM "h2o_feet" WHERE time >= '2015-08-18T00:00:00Z' AND time < '2015-09-18T17:00:00Z' GROUP BY time(4d)
name: h2o_feet
--------------
time                           count
2015-08-17T00:00:00Z     1440
2015-08-21T00:00:00Z     1920
2015-08-25T00:00:00Z     1920
2015-08-29T00:00:00Z     1920
2015-09-02T00:00:00Z     1915
2015-09-06T00:00:00Z     1920
2015-09-10T00:00:00Z     1920
2015-09-14T00:00:00Z     1920
2015-09-18T00:00:00Z     335
  • h2o_feet有两个数据字段level descriptionwater_level,可以通过count(*) 统计所有的字段
> SELECT COUNT(*) FROM "h2o_feet"
name: h2o_feet
--------------
time                   count_level description      count_water_level
1970-01-01T00:00:00Z   15258                       15258

1.2 DISTINCT()

说明:返回字段的唯一值(去重)
语法

SELECT DISTINCT(<field_key>) FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

例子:

  • 全表单字段
> SELECT DISTINCT("level description") FROM "h2o_feet"
name: h2o_feet
--------------
time                           distinct
1970-01-01T00:00:00Z     between 6 and 9 feet
1970-01-01T00:00:00Z     below 3 feet
1970-01-01T00:00:00Z     between 3 and 6 feet
1970-01-01T00:00:00Z     at or greater than 9 feet
  • 分组单字段
> SELECT DISTINCT("level description") FROM "h2o_feet" GROUP BY "location"
name: h2o_feet
tags: location=coyote_creek
time                            distinct
----                            --------
1970-01-01T00:00:00Z      between 6 and 9 feet
1970-01-01T00:00:00Z      between 3 and 6 feet
1970-01-01T00:00:00Z      below 3 feet
1970-01-01T00:00:00Z      at or greater than 9 feet

name: h2o_feet
tags: location=santa_monica
time                            distinct
----                            --------
1970-01-01T00:00:00Z      below 3 feet
1970-01-01T00:00:00Z      between 3 and 6 feet
1970-01-01T00:00:00Z      between 6 and 9 feet
  • 多字段
> SELECT DISTINCT(*) FROM "h2o_feet" LIMIT 5
name: h2o_feet
--------------
time                   distinct_level description    distinct_water_level
1970-01-01T00:00:00Z   below 3 feet                  2.064
1970-01-01T00:00:00Z   between 6 and 9 feet          8.12
1970-01-01T00:00:00Z                                 2.116
1970-01-01T00:00:00Z                                 8.005
1970-01-01T00:00:00Z                                 2.028

1.3 MEAN()

说明:算术平均值,字段类型必须为整型(int64)或浮点型(float64)
语法

SELECT MEAN(<field_key>) FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

例子:

  • 时间在2016-08-18T00:00:00Z2016-09-18T17:00:00Z之间,按4天(time(4d))进行分组
> SELECT MEAN("water_level") FROM "h2o_feet" WHERE time >= '2015-08-18T00:00:00Z' AND time < '2015-09-18T17:00:00Z' GROUP BY time(4d)
name: h2o_feet
--------------
time                     mean
2016-08-17T00:00:00Z     4.322029861111125
2016-08-21T00:00:00Z     4.251395512375667
2016-08-25T00:00:00Z     4.285036458333324
2016-08-29T00:00:00Z     4.469495801899061
2016-09-02T00:00:00Z     4.382785378590083
2016-09-06T00:00:00Z     4.28849666349042
...

1.4 MEDIAN()

说明:返回中位数,字段类型必须为整型(int64)或浮点型(float64),*表示所有字段
语法

SELECT MEDIAN(<field_key>) FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

例子:

> SELECT MEDIAN("water_level") FROM "h2o_feet" WHERE time >= '2015-08-18T00:00:00Z' AND time < '2015-08-18T00:36:00Z' GROUP BY "location"
name: h2o_feet
tags: location = coyote_creek
time                           median
----                           ------
2015-08-18T00:00:00Z     7.8245

name: h2o_feet
tags: location = santa_monica
time                           median
----                           ------
2015-08-18T00:00:00Z     2.0575

1.5 MODE()

说明:返回最频繁的(出现频率最高的)值,如果有多个频率相同的值则返回第一个(最早的)
语法

SELECT MODE(<field_key>) FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

例子:

> SELECT MODE("water_level") FROM "h2o_feet" WHERE time >= '2015-08-18T00:00:00Z' AND time < '2015-08-18T00:36:00Z' GROUP BY "location"
name: h2o_feet
tags: location = coyote_creek
time                           mode
----                           ------
2015-08-18T00:00:00Z     7

name: h2o_feet
tags: location = santa_monica
time                           mode
----                           ------
2015-08-18T00:00:00Z     2

1.5 SPREAD()

说明:返回字段的最小值和最大值之间的差值。 该字段必须是int64float64类型; *表示表中的所有int64float64字段。

语法

SELECT SPREAD(<field_key>) FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

例子:

> SELECT SPREAD("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-09-18T17:00:00Z' AND time < '2015-09-18T20:30:00Z' GROUP BY time(30m)
name: h2o_feet
--------------
time                            spread
2015-09-18T17:00:00Z      0.16699999999999982
2015-09-18T17:30:00Z      0.5469999999999997
2015-09-18T18:00:00Z      0.47499999999999964
2015-09-18T18:30:00Z      0.2560000000000002
2015-09-18T19:00:00Z      0.23899999999999988
2015-09-18T19:30:00Z      0.1609999999999996
2015-09-18T20:00:00Z      0.16800000000000015

1.6 SUM()

说明:返回单个字段中所有值的总和。 该字段必须是int64float64类型; *表示表中的所有int64float64字段。

语法

SELECT SUM(<field_key>) FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

例子:

> SELECT SUM("water_level") FROM "h2o_feet" WHERE time >= '2015-08-18T00:00:00Z' AND time < '2015-09-18T17:00:00Z' GROUP BY time(5d)
name: h2o_feet
--------------
time                           sum
2015-08-18T00:00:00Z     10334.908999999983
2015-08-23T00:00:00Z     10113.356999999995
2015-08-28T00:00:00Z     10663.683000000006
2015-09-02T00:00:00Z     10451.321
2015-09-07T00:00:00Z     10871.817999999994
2015-09-12T00:00:00Z     11459.00099999999
2015-09-17T00:00:00Z     3627.762000000003

1.7 STDDEV()

说明:返回单个字段中的值的标准偏差。 该字段必须是int64float64类型。
语法

SELECT STDDEV(<field_key>) FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

2. 选择器函数

2.1 BOTTOM()

说明:返回单个字段中最小的N个值。 字段类型必须为int64float64。当同步指定tag时,设定tag的记录数是X,如果N>X时只返回X条记录,每个tag一条,否则返回最小的N条数据。
语法

SELECT BOTTOM(<field_key>[,<tag_keys>],<N>)[,<tag_keys>] FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

2.2 FIRST()

说明:返回单个字段的最旧值(由时间戳确定)。
语法

SELECT FIRST(<field_key>)[,<tag_key(s)>] FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

2.3 LAST()

说明:返回单个字段的最新值(由时间戳确定)。

SELECT LAST(<field_key>)[,<tag_key(s)>] FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

2.4 MAX()

说明:返回单个字段中的最大值。 该字段必须是int64float64boolean
语法

SELECT MAX(<field_key>)[,<tag_key(s)>] FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

2.5 MIN()

说明:返回单个字段中的最小值。 该字段必须是int64float64boolean
语法

SELECT MIN(<field_key>)[,<tag_key(s)>] FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

2.6 PERCENTILE()

说明:返回单个字段的排序值的第N个百分位数值。 该字段必须是int64float64类型。 百分位数N必须是0100之间的整数或浮点数,包括0100。算法找度娘。
语法

SELECT PERCENTILE(<field_key>, <N>)[,<tag_key(s)>] FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

2.7 SAMPLE()

说明:返回指定字段的N个点的随机抽样。 InfluxDB使用储层采样来生成随机点。 SAMPLE()支持所有字段类型。
语法

SELECT SAMPLE(<field_key>,<N>) FROM_clause [WHERE_clause] [GROUP_BY_clause]

2.8 TOP()

说明:返回单个字段中最大的N个值。 字段类型必须为int64float64
语法

SELECT TOP(<field_key>[,<tag_keys>],<N>)[,<tag_keys>] FROM <measurement_name> [WHERE <stuff>] [GROUP BY <stuff>]

3. 转换函数

3.1 CUMULATIVE_SUM()

说明:返回单个字段的连续字段值的累积和。 字段类型必须为int64float64
基础语法

SELECT CUMULATIVE_SUM(<field_key>) FROM_clause WHERE_clause

高级语法
支持如下嵌套函数类型:COUNT()
, MEAN()
, MEDIAN()
, MODE()
, SUM()
, FIRST()
, LAST()
, MIN()
,MAX()
, and PERCENTILE()
.

SELECT CUMULATIVE_SUM(<function>(<field_key>)) FROM_clause WHERE_clause GROUP BY time(<interval>)[,<tag_key>]

例子

##原数据
> SELECT "water_level" FROM "h2o_feet" WHERE time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:30:00Z' AND "location" = 'santa_monica'
name: h2o_feet
time                   water_level
----                   -----------
2015-08-18T00:00:00Z   2.064
2015-08-18T00:06:00Z   2.116
2015-08-18T00:12:00Z   2.028
2015-08-18T00:18:00Z   2.126
2015-08-18T00:24:00Z   2.041
2015-08-18T00:30:00Z   2.051
##转换后数据
> SELECT CUMULATIVE_SUM("water_level") FROM "h2o_feet" WHERE time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:30:00Z' AND "location" = 'santa_monica'
name: h2o_feet
time                   cumulative_sum
----                   --------------
2015-08-18T00:00:00Z   2.064
2015-08-18T00:06:00Z   4.18
2015-08-18T00:12:00Z   6.208
2015-08-18T00:18:00Z   8.334
2015-08-18T00:24:00Z   10.375
2015-08-18T00:30:00Z   12.426

3.2 DERIVATIVE()

说明:返回系列中单个字段中值的变化率。 InfluxDB计算时间域值之间的差异,并将这些结果转换为单位变化率。 单位参数是可选的,如果未指定,则默认为1秒(1秒)。
基础语法

SELECT DERIVATIVE(<field_key>, [<unit>]) FROM <measurement_name> [WHERE <stuff>]

单位unit可以有如下值:

  • u or µ微妙(microseconds)
  • ms 毫秒(milliseconds)
  • s 秒(seconds)
  • m 分(minutes)
  • h 时(hours)
  • d 天(days)
  • w 周(weeks)

使用聚合函数语法

SELECT DERIVATIVE(AGGREGATION_FUNCTION(<field_key>),[<unit>]) FROM <measurement_name> WHERE <stuff> GROUP BY time(<aggregation_interval>)

例子

#原数据,两条数据直接间隔6分钟
> SELECT "water_level" FROM "h2o_feet" WHERE "location" = 'santa_monica' LIMIT 5
name: h2o_feet
--------------
time                           water_level
2015-08-18T00:00:00Z     2.064
2015-08-18T00:06:00Z     2.116
2015-08-18T00:12:00Z     2.028
2015-08-18T00:18:00Z     2.126
2015-08-18T00:24:00Z     2.041
2015-08-18T00:30:00Z     2.051

#不指定单位时,默认为每秒变化率,如第一条记录(`(2.116-2.064)/(6m/1s)`)
> SELECT DERIVATIVE("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica' LIMIT 5
name: h2o_feet
--------------
time                           derivative
2015-08-18T00:06:00Z     0.00014444444444444457
2015-08-18T00:12:00Z     -0.00024444444444444465
2015-08-18T00:18:00Z     0.0002722222222222218
2015-08-18T00:24:00Z     -0.000236111111111111
2015-08-18T00:30:00Z     2.777777777777842e-05

#每6分钟变化率,如第一条(`(2.116-2.064)/(6m/6m)`)
> SELECT DERIVATIVE("water_level",6m) FROM "h2o_feet" WHERE "location" = 'santa_monica' LIMIT 5
name: h2o_feet
--------------
time                           derivative
2015-08-18T00:06:00Z     0.052000000000000046
2015-08-18T00:12:00Z     -0.08800000000000008
2015-08-18T00:18:00Z     0.09799999999999986
2015-08-18T00:24:00Z     -0.08499999999999996
2015-08-18T00:30:00Z     0.010000000000000231

#每12分钟变化率,如第一条(`(2.116-2.064)/(6m/12m)`)
> SELECT DERIVATIVE("water_level",12m) FROM "h2o_feet" WHERE "location" = 'santa_monica' LIMIT 5
name: h2o_feet
--------------
time                           derivative
2015-08-18T00:06:00Z     0.10400000000000009
2015-08-18T00:12:00Z     -0.17600000000000016
2015-08-18T00:18:00Z     0.19599999999999973
2015-08-18T00:24:00Z     -0.16999999999999993
2015-08-18T00:30:00Z     0.020000000000000462

#每隔12分钟最大值
> SELECT MAX("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time < '2015-08-18T00:36:00Z' GROUP BY time(12m)
name: h2o_feet
--------------
time                           max
2015-08-18T00:00:00Z     2.116
2015-08-18T00:12:00Z     2.126
2015-08-18T00:24:00Z     2.051
#每隔12分钟变化率,如第一条(`(2.126-2.116)/(12m-12m)`),带group by 语句时unit默认为time函数指定的间隔
> SELECT DERIVATIVE(MAX("water_level")) FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time < '2015-08-18T00:36:00Z' GROUP BY time(12m)
name: h2o_feet
--------------
time                           derivative
2015-08-18T00:12:00Z     0.009999999999999787
2015-08-18T00:24:00Z     -0.07499999999999973

#每隔18分钟汇总数据
> SELECT SUM("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time < '2015-08-18T00:36:00Z' GROUP BY time(18m)
name: h2o_feet
--------------
time                           sum
2015-08-18T00:00:00Z     6.208
2015-08-18T00:18:00Z     6.218

#每隔18分钟汇总数据没6分钟变化率,如第一条(`(6.218-6.208)/(18m/6m)`)
> SELECT DERIVATIVE(SUM("water_level"),6m) FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time < '2015-08-18T00:36:00Z' GROUP BY time(18m)
name: h2o_feet
--------------
time                           derivative
2015-08-18T00:18:00Z     0.0033333333333332624

3.3 DIFFERENCE()

说明:返回单个字段中连续的时间顺序值之间的差异。 字段类型必须为int64float64
基础语法

SELECT DIFFERENCE(<field_key>) FROM <measurement_name> [WHERE <stuff>]

高级语法

SELECT DIFFERENCE(<function>(<field_key>)) FROM <measurement_name> WHERE <stuff> GROUP BY time(<time_interval>)

支持的内嵌函数包括:COUNT()
, MEAN()
, MEDIAN()
, SUM()
, FIRST()
,LAST()
, MIN()
, MAX()
, and PERCENTILE()

例子

#带处理数据
> SELECT "water_level" FROM "h2o_feet" WHERE "location"='santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z'
name: h2o_feet
--------------
time                            water_level
2015-08-18T00:00:00Z      2.064
2015-08-18T00:06:00Z      2.116
2015-08-18T00:12:00Z      2.028
2015-08-18T00:18:00Z      2.126
2015-08-18T00:24:00Z      2.041
2015-08-18T00:30:00Z      2.051
2015-08-18T00:36:00Z      2.067
#处理后
> SELECT DIFFERENCE("water_level") FROM "h2o_feet" WHERE "location"='santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z'
name: h2o_feet
--------------
time                            difference
2015-08-18T00:06:00Z      0.052000000000000046
2015-08-18T00:12:00Z      -0.08800000000000008
2015-08-18T00:18:00Z      0.09799999999999986
2015-08-18T00:24:00Z      -0.08499999999999996
2015-08-18T00:30:00Z      0.010000000000000231
2015-08-18T00:36:00Z      0.016000000000000014
#分组统计后数据
> SELECT MIN("water_level") FROM "h2o_feet" WHERE "location"='santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z' GROUP BY time(12m)
name: h2o_feet
--------------
time                            min
2015-08-18T00:00:00Z    2.064
2015-08-18T00:12:00Z    2.028
2015-08-18T00:24:00Z    2.041
2015-08-18T00:36:00Z    2.067
#分组统计处理后数据
> SELECT DIFFERENCE(MIN("water_level")) FROM "h2o_feet" WHERE "location"='santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z' GROUP BY time(12m)
name: h2o_feet
--------------
time                            difference
2015-08-18T00:12:00Z      -0.03600000000000003
2015-08-18T00:24:00Z      0.0129999999999999
2015-08-18T00:36:00Z      0.026000000000000245

3.4 ELAPSED()

说明:返回单个字段中后续时间戳之间的差异。 持续时间(unit)参数是可选的,如果未指定,则默认为一纳秒。
语法

SELECT ELAPSED(<field_key>, <unit>) FROM <measurement_name> [WHERE <stuff>]

例子

#原数据
> SELECT "water_level" FROM "h2o_feet" WHERE "location"='santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z'
name: h2o_feet
--------------
time                            water_level
2015-08-18T00:00:00Z      2.064
2015-08-18T00:06:00Z      2.116
2015-08-18T00:12:00Z      2.028
2015-08-18T00:18:00Z      2.126
2015-08-18T00:24:00Z      2.041
#每两个`water_level`数据记录直接的时间间隔是6分钟(即360000000000纳秒),elapsed = 6m/1纳秒
> SELECT ELAPSED("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:24:00Z'
name: h2o_feet
--------------
time                            elapsed
2015-08-18T00:06:00Z      360000000000
2015-08-18T00:12:00Z      360000000000
2015-08-18T00:18:00Z      360000000000
2015-08-18T00:24:00Z      360000000000
#每两个`water_level`数据记录直接的时间间隔是6分钟,elapsed = 6m/1m
> SELECT ELAPSED("water_level",1m) FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:24:00Z'
name: h2o_feet
--------------
time                            elapsed
2015-08-18T00:06:00Z      6
2015-08-18T00:12:00Z      6
2015-08-18T00:18:00Z      6
2015-08-18T00:24:00Z      6
#每两个`water_level`数据记录直接的时间间隔是6分钟,elapsed = 6m / 1h。因为1h>6m,所以数据为0
> SELECT ELAPSED("water_level",1h) FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:24:00Z'
name: h2o_feet
--------------
time                            elapsed
2015-08-18T00:06:00Z      0
2015-08-18T00:12:00Z      0
2015-08-18T00:18:00Z      0
2015-08-18T00:24:00Z      0

3.5 MOVING_AVERAGE()

说明:返回单个字段的连续window个字段值的滑动平均值。 字段类型必须为int64float64。算法找度娘
基础语法

SELECT MOVING_AVERAGE(<field_key>,<window>) FROM <measurement_name> [WHERE <stuff>]

高级语法

SELECT MOVING_AVERAGE(<function>(<field_key>),<window>) FROM <measurement_name> WHERE <stuff> GROUP BY time(<time_interval>)

支持的函数包括:COUNT()
, MEAN()
, MEDIAN()
, SUM()
, FIRST()
,LAST()
, MIN()
, MAX()
, and PERCENTILE()

例子

> SELECT "water_level" FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z'
name: h2o_feet
--------------
time                            water_level
2015-08-18T00:00:00Z      2.064
2015-08-18T00:06:00Z      2.116
2015-08-18T00:12:00Z      2.028
2015-08-18T00:18:00Z      2.126
2015-08-18T00:24:00Z      2.041
2015-08-18T00:30:00Z      2.051
2015-08-18T00:36:00Z      2.067
#第一条(`(2.116+2.064)/2`),第二条(`(2.028+2.116)/2`)
> SELECT MOVING_AVERAGE("water_level",2) FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z'
name: h2o_feet
--------------
time                            moving_average
2015-08-18T00:06:00Z      2.09
2015-08-18T00:12:00Z      2.072
2015-08-18T00:18:00Z      2.077
2015-08-18T00:24:00Z      2.0835
2015-08-18T00:30:00Z      2.0460000000000003
2015-08-18T00:36:00Z      2.059
#分组统计
> SELECT MIN("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z' GROUP BY time(12m)
name: h2o_feet
--------------
time                            min
2015-08-18T00:00:00Z      2.064
2015-08-18T00:12:00Z      2.028
2015-08-18T00:24:00Z      2.041
2015-08-18T00:36:00Z      2.067
#分组统计滑动平均值,第一条(`(2.064+2.028)/2`)
> SELECT MOVING_AVERAGE(MIN("water_level"),2) FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:36:00Z' GROUP BY time(12m)
name: h2o_feet
--------------
time                            moving_average
2015-08-18T00:12:00Z      2.0460000000000003
2015-08-18T00:24:00Z      2.0345000000000004
2015-08-18T00:36:00Z      2.0540000000000003

3.6 NON_NEGATIVE_DERIVATIVE()

说明:返回系列中单个字段中的值的非负变化率。 InfluxDB计算时间域值之间的差异,并将这些结果转换为单位变化率。 单位参数是可选的,如果未指定,则默认为1秒(1秒)。改函数和DERIVATIVE()函数类似,只是返回其正数结果。
语法

SELECT NON_NEGATIVE_DERIVATIVE(<field_key>, [<unit>]) FROM <measurement_name> [WHERE <stuff>]

SELECT NON_NEGATIVE_DERIVATIVE(AGGREGATION_FUNCTION(<field_key>),[<unit>]) FROM <measurement_name> WHERE <stuff> GROUP BY time(<aggregation_interval>)

4. 预测函数

4.1 HOLT_WINTERS()

说明:霍尔特指数平滑法,该字段必须是int64float64类型。算法找度娘。
语法

SELECT HOLT_WINTERS(FUNCTION(<field_key>),<N>,<S>) FROM <measurement_name> WHERE <stuff> GROUP BY time(<interval>)[,<stuff>]

SELECT HOLT_WINTERS_WITH_FIT(FUNCTION(<field_key>),<N>,<S>) FROM <measurement_name> WHERE <stuff> GROUP BY time(<interval>)[,<stuff>]
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,743评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,296评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,285评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,485评论 1 283
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,581评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,821评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,960评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,719评论 0 266
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,186评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,516评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,650评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,329评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,936评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,757评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,991评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,370评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,527评论 2 349

推荐阅读更多精彩内容