experimental.to() function
The experimental.to()
function is subject to change at any time.
By using this function, you accept the risks of experimental functions.
The experimental.to()
function writes data to an InfluxDB v2.0 bucket, but in
a different structure than the
to()
function.
import "experimental"
experimental.to(
bucket: "my-bucket",
org: "my-org",
host: "http://localhost:8086",
token: "mY5uPeRs3Cre7tok3N",
)
// OR
experimental.to(
bucketID: "1234567890",
orgID: "0987654321",
host: "http://localhost:8086",
token: "mY5uPeRs3Cre7tok3N",
)
Expected data structure
Data structure expected by built-in to()
The built-in to()
function requires _time
, _measurement
, _field
, and _value
columns.
The _field
column stores the field key and the _value
column stores the field value.
_time | _measurement | _field | _value |
---|---|---|---|
timestamp | measurement-name | field key | field value |
Data structure expected by experimental to()
experimental.to()
requires both a _time
and a _measurement
column.
All columns in the group key (other than _measurement
) are written as tags
with the column name as the tag key and the column value as the tag value.
All columns not in the group key (other than _time
) are written as fields
with the column name as the field key and the column value as the field value.
_time | _measurement | field_key |
---|---|---|
timestamp | measurement-name | field value |
If using the built-in from()
function, use pivot()
to transform data into the structure experimetnal.to()
expects.
See the example below.
Parameters
bucket
The bucket to write data to.
bucket
and bucketID
are mutually exclusive.
bucketID
The ID of the bucket to write data to.
bucketID
and bucket
are mutually exclusive.
org
The organization name of the specified bucket
.
Only required when writing to a different organization or a remote host.
org
and orgID
are mutually exclusive.
orgID
The organization ID of the specified bucket
.
Only required when writing to a different organization or a remote host.
orgID
and org
are mutually exclusive.
experimental.to()
cannot write to from one InfluxDB Cloud organization to another.
host
InfluxDB URL or InfluxDB Cloud region URL to write to.
host
is required when writing to a remote InfluxDB instance.
If specified, token
is also required.
token
token
is required when writing to another organization or when writing to a remote InfluxDB host
.
tables
Input data.
Default is piped-forward data (<-
).
Examples
Use pivot() to shape data for experimental.to()
import "experimental"
from(bucket: "example-bucket")
|> range(start: -1h)
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
|> experimental.to(bucket: "bucket-name", org: "org-name")
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.