range() function
range()
根据时间范围过滤行。
输入数据必须具有 _time
列,类型为时间类型。 _time
列中包含空值的行将被过滤掉。 range()
添加一个 _start
列,其值为 start
,以及一个 _stop
列,其值为 stop
。 _start
和 _stop
列被添加到组键中。 每个输入表的组键值都会被修改以适应时间范围。 所有行都在时间范围之外的表将被完全过滤掉。
函数类型签名
(<-tables: stream[{C with _time: time}], start: A, ?stop: B) => stream[{C with _time: time, _stop: time, _start: time}]
有关更多信息,请参阅 函数类型签名。
参数
start
(必填) 结果中包含的最早时间。
结果包含 _time
值与指定的开始时间匹配的行。 使用相对持续时间、绝对时间或整数(Unix 时间戳,以秒为单位)。 例如,-1h
、2019-08-28T22:00:00Z
或 1567029600
。 持续时间相对于 now()
。
stop
结果中包含的最新时间。 默认为 now()
。
结果不包括 _time
值与指定的停止时间相匹配的行。可以使用相对持续时间、绝对时间或整数(Unix 时间戳,以秒为单位)。例如,-1h
、2019-08-28T22:00:00Z
或 1567029600
。持续时间是相对于 now()
的。
tables
输入数据。默认值是管道转发的数据 (<-
)。
示例
查询相对于现在的某个时间范围
from(bucket: "example-bucket")
|> range(start: -12h)
查询绝对时间范围
from(bucket: "example-bucket")
|> range(start: 2021-05-22T23:30:00Z, stop: 2021-05-23T00:00:00Z)
使用 Unix 时间戳查询绝对时间范围
from(bucket: "example-bucket")
|> range(start: 1621726200, stop: 1621728000)
此页面是否对您有帮助?
感谢您的反馈!