Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
InfluxDB通量-字段与值匹配的过滤器_Influxdb_Influxql - Fatal编程技术网

InfluxDB通量-字段与值匹配的过滤器

InfluxDB通量-字段与值匹配的过滤器,influxdb,influxql,Influxdb,Influxql,我使用with,我有一个名为items的度量,带有一些标记和一个名为itemType的字段。我需要筛选itemType是特定字符串的行。以下InfluxQL查询正是我所需要的: SELECT * FROM "items" WHERE "itemType" = 'example' 我怎样才能做到同样的事情呢 我目前有以下查询,除了按字段过滤外,它执行所有操作: from(bucket: "dbname/autogen") |&g

我使用with,我有一个名为
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)