0

将 InfluxQL 与此查询一起使用,可以将表从 转换FloatInteger

SELECT value::integer INTO temp FROM measurement;
DROP MEASUREMENT measurement;
SELECT value::integer INTO measurement FROM temp;
DROP MEASUREMENT temp;

如何Flux在 InfluxDB 2 中使用同样的方法?

InfluxDB 2 有一个 InfluxDB 1 兼容层,但这不支持SELECT ... INTO ...子句:https ://docs.influxdata.com/influxdb/v2.1/reference/api/influxdb-1x/#influxql-support 所以必须使用Flux新的查询语言编写查询。

4

1 回答 1

0
  1. 创建temp存储桶
  2. 运行此查询:
from(bucket: "<bucket>")
  |> range(start: 1970-01-01T00:00:00Z, stop: now())
  |> filter(fn: (r) => r["_measurement"] == "<measurement>")
  |> filter(fn: (r) => r["_field"] == "value")
  |> toInt()
  |> to(bucket: "temp", org: "<org>")
  1. 通过命令行<measurement>插入:<bucket>
influx delete --bucket <bucket> --start '2010-01-01T00:00:00Z' --stop $(date +"%Y-%m-%dT%H:%M:%SZ") --predicate '_measurement="<measurement>"' --org <org> --token <token>
  1. 运行此查询:
from(bucket: "temp")
  |> range(start: 1970-01-01T00:00:00Z, stop: now())
  |> filter(fn: (r) => r["_measurement"] == "<measurement>")
  |> filter(fn: (r) => r["_field"] == "value")
  |> to(bucket: "<bucket>", org: "<org>"
  1. 从 2. 重复您要转换的所有测量值

  2. temp

于 2021-12-06T16:38:31.903 回答