【发布时间】:2021-01-29 11:10:25
【问题描述】:
我正在使用InfluxDB 和Grafana,并且我有一个名为items 的测量值,其中包含一些标签和一个名为itemType 的字段。我需要过滤 itemType 是某个字符串的行。以下 InfluxQL 查询正是我所需要的:
SELECT * FROM "items" WHERE "itemType" = 'example'
我怎样才能在Flux 中做同样的事情?
我目前有以下查询,除了按字段过滤之外,它可以执行所有操作:
from(bucket: "dbname/autogen")
|> range(start: 2020-10-12T01:56:34Z, stop: 2020-10-12T02:54:10Z)
|> filter(fn:(r) => r._measurement == "items")
|> aggregateWindow(every: 5m, fn: count)
但是用 filter(fn:(r) => r._measurement == "items" and r.itemType == "example") 替换 filter 函数不会返回任何结果,即使上面的 InfluxQL 查询在 InfluxDB CLI 中使用时确实返回数据。
【问题讨论】: