query.inBucket() 函数
query.inBucket()
是实验性的,并且随时可能更改。
query.inBucket()
从指定 InfluxDB 存储桶中查询给定时间范围内的数据,按测量、字段和可选的谓词表达式过滤数据。
函数类型签名
(
bucket: string,
measurement: A,
start: B,
?fields: [string],
?predicate: (
r: {
C with
_value: D,
_time: time,
_stop: time,
_start: time,
_measurement: string,
_field: string,
},
) => bool,
?stop: E,
) => stream[{
C with
_value: D,
_time: time,
_stop: time,
_start: time,
_measurement: string,
_field: string,
}] where A: Equatable
更多信息,请参阅函数类型签名。
参数
bucket
(必需)InfluxDB 存储桶名称。
measurement
(必需)要筛选的 InfluxDB 测量名称。
start
(必需)结果中包含的最早时间。
结果包括与指定的开始时间匹配的点。使用相对持续时间、绝对时间或整数(Unix 时间戳,以秒为单位)。例如,-1h
、2019-08-28T22:00:00Z
或 1567029600
。持续时间相对于 now()
。
stop
结果中包含的最新时间。默认为 now()
。
结果不包括与指定的停止时间匹配的点。使用相对持续时间、绝对时间或整数(Unix 时间戳,以秒为单位)。例如,-1h
、2019-08-28T22:00:00Z
或 1567029600
。持续时间相对于 now()
。
fields
要筛选的字段。默认为 []
。
predicate
谓词函数,用于评估列值并返回 true
或 false
。默认为 (r) => true
。
记录 (r
) 被传递给函数。评估结果为 true
的记录包含在输出表中。评估结果为 null 或 false
的记录不包含在输出表中。
示例
从 InfluxDB 查询测量中的特定字段
import "experimental/query"
query.inBucket(
bucket: "example-buckt",
start: -1h,
measurement: "mem",
fields: ["field1", "field2"],
predicate: (r) => r.host == "host1",
)
此页是否对您有帮助?
感谢您的反馈!