Influx DB - 第一个/最后一个值

时间:2016-05-19 08:57:47

标签: influxdb

我从流入数据库timeseries中选择最后一分钟的第一个和最后一个值,以下是请求:

echo -e 'LAST VALUE' && \
curl -G 'http://db_address:8086/query?q=select+last(value)+from+ambient_temperature+where+time>now()+-+1m&db=home_data' && \
echo -e '\nFIRST VALUE' && \
curl -G 'http://db_address:8086/query?q=select+first(value)+from+ambient_temperature+where+time>now()+-+1m&db=home_data' && \
echo -e '\nlast values' && \
curl -G 'http://db_address:8086/query?q=select+*+from+ambient_temperature+where+time>now()+-+2m&db=home_data'

LAST VALUE
{"results":[{"series":[{"name":"ambient_temperature","columns":["time","last"],"values":[["2016-05-19T08:43:09.645833512Z",20.71875]]}]}]}
FIRST VALUE
{"results":[{"series":[{"name":"ambient_temperature","columns":["time","first"],"values":[["2016-05-19T08:43:09.700503355Z",20.71875]]}]}]}
last values
{"results":[{"series":[{"name":"ambient_temperature","columns":["time","value"],"values":[["2016-05-19T08:42:11.69Z",20.71875],["2016-05-19T08:42:13.715Z",20.71875],["2016-05-19T08:42:15.695    Z",20.71875],["2016-05-19T08:42:17.705Z",20.71875],["2016-05-19T08:42:19.714Z",20.71875],["2016-05-19T08:42:21.71Z",20.71875],["2016-05-19T08:42:23.719Z",20.71875],["2016-05-19T08:42:25.729Z    ",20.71875],["2016-05-19T08:42:27.724Z",20.71875],["2016-05-19T08:42:29.734Z",20.71875],["2016-05-19T08:42:31.788Z",20.71875],["2016-05-19T08:42:33.783Z",20.71875],["2016-05-19T08:42:35.764Z    ",20.71875],["2016-05-19T08:42:37.758Z",20.71875],["2016-05-19T08:42:39.753Z",20.71875],["2016-05-19T08:42:41.793Z",20.71875],["2016-05-19T08:42:43.772Z",20.71875],["2016-05-19T08:42:45.782Z    ",20.71875],["2016-05-19T08:42:47.777Z",20.71875],["2016-05-19T08:42:49.787Z",20.71875],["2016-05-19T08:42:51.782Z",20.71875],["2016-05-19T08:42:53.792Z",20.71875],["2016-05-19T08:42:55.846Z    ",20.71875],["2016-05-19T08:42:57.796Z",20.71875],["2016-05-19T08:42:59.807Z",20.71875],["2016-05-19T08:43:01.816Z",20.71875],["2016-05-19T08:43:03.841Z",20.71875],["2016-05-19T08:43:05.851Z    ",20.71875],["2016-05-19T08:43:07.831Z",20.71875],["2016-05-19T08:43:09.855Z",20.71875],["2016-05-19T08:43:11.865Z",20.71875],["2016-05-19T08:43:13.86Z",20.71875],["2016-05-19T08:43:15.84Z",    20.71875],["2016-05-19T08:43:17.85Z",20.71875],["2016-05-19T08:43:19.859Z",20.71875],["2016-05-19T08:43:21.869Z",20.71875],["2016-05-19T08:43:23.864Z",20.71875],["2016-05-19T08:43:25.874Z",2    0.71875],["2016-05-19T08:43:27.869Z",20.71875],["2016-05-19T08:43:29.879Z",20.71875],["2016-05-19T08:43:31.919Z",20.71875],["2016-05-19T08:43:33.883Z",20.71875],["2016-05-19T08:43:35.893Z",2    0.71875],["2016-05-19T08:43:37.903Z",20.71875],["2016-05-19T08:43:39.899Z",20.71875],["2016-05-19T08:43:41.908Z",20.71875],["2016-05-19T08:43:43.918Z",20.71875],["2016-05-19T08:43:45.913Z",2    0.71875],["2016-05-19T08:43:47.937Z",20.71875],["2016-05-19T08:43:49.932Z",20.71875],["2016-05-19T08:43:51.942Z",20.71875],["2016-05-19T08:43:53.937Z",20.71875],["2016-05-19T08:43:55.947Z",2    0.71875],["2016-05-19T08:43:57.972Z",20.71875],["2016-05-19T08:43:59.981Z",20.71875],["2016-05-19T08:44:01.976Z",20.71875],["2016-05-19T08:44:03.971Z",20.71875],["2016-05-19T08:44:05.981Z",2    0.71875],["2016-05-19T08:44:07.991Z",20.71875]]}]}]}

但是我不理解返回的结果,对于最后和第一个值,我得到的时间与我的系列中的任何时间都不匹配(请参阅查询最近2分钟的值的最后一个请求),我应该有时间:

    第一个元素
  • 2016-05-19T08:42:11.69Z
  • 2016-05-19T08:44:07.991Z代表最后一个元素

第一个和最后一个值的时间来自哪里? 为什么第一个和最后一个值不合理?

1 个答案:

答案 0 :(得分:0)

以下是来自Influxdb的回复: https://github.com/influxdata/influxdb/issues/6684