InfluxDB通量-字段与值匹配的过滤器
我使用with,我有一个名为InfluxDB通量-字段与值匹配的过滤器,influxdb,influxql,Influxdb,Influxql,我使用with,我有一个名为items的度量,带有一些标记和一个名为itemType的字段。我需要筛选itemType是特定字符串的行。以下InfluxQL查询正是我所需要的: SELECT * FROM "items" WHERE "itemType" = 'example' 我怎样才能做到同样的事情呢 我目前有以下查询,除了按字段过滤外,它执行所有操作: from(bucket: "dbname/autogen") |&g
items
的度量,带有一些标记和一个名为itemType
的字段。我需要筛选itemType
是特定字符串的行。以下InfluxQL查询正是我所需要的:
SELECT * FROM "items" WHERE "itemType" = 'example'
我怎样才能做到同样的事情呢
我目前有以下查询,除了按字段过滤外,它执行所有操作:
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
函数替换为filter(fn:(r)=>r._measurement==“items”和r.itemType==“example”)
不返回结果,即使上面的InfluxQL查询在InfluxDB CLI中使用时返回数据。如果itemType是一个标记,则指定的流量查询将工作,由于它是一个字段,因此执行查询的方法之一是对字段名及其值设置条件,如下所示:
from(bucket: "dbname/autogen")
|> range(start: 2020-10-12T01:56:34Z, stop: 2020-10-12T02:54:10Z)
|> filter(fn:(r) => r._measurement == "items" and r._field == "itemType" and r._value == "example")
|> aggregateWindow(every: 5m, fn: count)