influxdb.wideTo() 函数
influxdb.wideTo()
将宽数据写入 InfluxDB 2.x 或 InfluxDB Cloud bucket。宽数据经过透视,其字段表示为列,使表格更宽。
要求和行为
- 需要
_time
和_measurement
列。 - 组键中的所有列(
_measurement
除外)都将作为标签写入,列名作为标签键,列值作为标签值。 - 不在组键中的所有列(
_time
除外)都将作为字段写入,列名作为字段键,列值作为字段值。
如果使用 from()
查询 InfluxDB 中的数据,请使用 pivot() 将数据转换为 experimental.to()
期望的结构。
函数类型签名
(
<-tables: stream[A],
?bucket: string,
?bucketID: string,
?host: string,
?org: string,
?orgID: string,
?token: string,
) => stream[A] where A: Record
有关更多信息,请参阅 函数类型签名。
参数
bucket
要写入的 bucket 的名称。bucket
和 bucketID
是互斥的。
bucketID
要写入的字符串编码的 bucket ID。bucket
和 bucketID
是互斥的。
host
要写入的 InfluxDB 实例的 URL。
请参阅 InfluxDB Cloud 区域 或 InfluxDB OSS URL。写入远程 InfluxDB 实例时,host
是必需的。如果指定,则 token
也是必需的。
org
组织名称。org
和 orgID
是互斥的。
orgID
要查询的字符串编码的组织 ID。org
和 orgID
是互斥的。
token
InfluxDB API 令牌。
InfluxDB 1.x 或 Enterprise:如果禁用身份验证,请提供空字符串 (""
)。如果启用身份验证,请使用 <username>:<password>
语法提供您的 InfluxDB 用户名和密码。写入另一个组织或指定 host
时,token
是必需的。
tables
输入数据。默认值为管道转发数据 (<-
)。
示例
透视并将数据写入 InfluxDB
import "influxdata/influxdb"
import "influxdata/influxdb/schema"
from(bucket: "example-bucket")
|> range(start: -1h)
|> schema.fieldsAsCols()
|> wideTo(bucket: "example-target-bucket")
此页是否对您有帮助?
感谢您的反馈!