content/flux/v0/stdlib/experimental/to.md
experimental.to() writes pivoted data to an InfluxDB 2.x or InfluxDB Cloud bucket.
{{% warn %}}
experimental.to() is deprecated in favor of wideTo(),
which is an equivalent function.
{{% /warn %}}
_time and a _measurement column._measurement) are written as tags
with the column name as the tag key and the column value as the tag value._time) are written as
fields with the column name as the field key and the column value as the field value.If using from() to query data from InfluxDB, use pivot() to transform
data into the structure experimental.to() expects.
(
<-tables: stream[A],
?bucket: string,
?bucketID: string,
?host: string,
?org: string,
?orgID: string,
?token: string,
) => stream[A] where A: Record
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Name of the bucket to write to.
bucket and bucketID are mutually exclusive.
String-encoded bucket ID to to write to.
bucket and bucketID are mutually exclusive.
URL of the InfluxDB instance to write to.
See InfluxDB Cloud regions
or InfluxDB OSS URLs.
host is required when writing to a remote InfluxDB instance.
If specified, token is also required.
Organization name.
org and orgID are mutually exclusive.
String-encoded organization ID to query.
org and orgID are mutually exclusive.
InfluxDB API token.
InfluxDB 1.x or Enterprise: If authentication is disabled, provide an
empty string (""). If authentication is enabled, provide your InfluxDB
username and password using the <username>:<password> syntax.
token is required when writing to another organization or when host
is specified.
Input data. Default is piped-forward data (<-).
import "experimental"
from(bucket: "example-bucket")
|> range(start: -1h)
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
|> experimental.to(bucket: "example-target-bucket")