You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

InfluxDB查询:如何筛选同时包含三个指定字段的数据行

解决方法

直接修改你的查询,去掉聚合窗口步骤,并添加过滤条件确保三个字段都存在:

from(bucket: "my_bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "my_data")
  |> filter(fn: (r) => r["_field"] == "temp1" or r["_field"] == "temp2" or r["_field"] == "temp3")
  |> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
  |> filter(fn: (r) => exists r.temp1 and exists r.temp2 and exists r.temp3)
  |> yield()

关键修改说明:

  • 移除了aggregateWindow步骤:这个函数会把指定时间窗口内的数据合并计算,不符合你"不合并时间范围数据"的要求,去掉后保留原始采集的时间戳行。
  • 添加了最后的filter:用exists函数检查每行的temp1、temp2、temp3三个字段是否都存在,只有三个字段都非空的行才会被保留。

内容的提问来源于stack exchange,提问作者jonas37

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 11:35:31