Documentation

influxdb.wideTo() function

influxdb.wideTo() writes wide data to an InfluxDB 2.x or InfluxDB Cloud bucket. Wide data is pivoted in that its fields are represented as columns making the table wider.

Requirements and behavior

  • 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.

If using the from() to query data from InfluxDB, use pivot() to transform data into the structure experimental.to() expects.

Function type signature
(
    <-tables: stream[A],
    ?bucket: string,
    ?bucketID: string,
    ?host: string,
    ?org: string,
    ?orgID: string,
    ?token: string,
) => stream[A] where A: Record

For more information, see Function type signatures.

Parameters

bucket

Name of the bucket to write to. bucket and bucketID are mutually exclusive.

bucketID

String-encoded bucket ID to to write to. bucket and bucketID are mutually exclusive.

host

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.

org

Organization name. org and orgID are mutually exclusive.

orgID

String-encoded organization ID to query. org and orgID are mutually exclusive.

token

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.

tables

Input data. Default is piped-forward data (<-).

Examples

Pivot and write data to InfluxDB

import "influxdata/influxdb"
import "influxdata/influxdb/schema"

from(bucket: "example-bucket")
    |> range(start: -1h)
    |> schema.fieldsAsCols()
    |> wideTo(bucket: "example-target-bucket")

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB v3 enhancements and InfluxDB Clustered is now generally available

New capabilities, including faster query performance and management tooling advance the InfluxDB v3 product line. InfluxDB Clustered is now generally available.

InfluxDB v3 performance and features

The InfluxDB v3 product line has seen significant enhancements in query performance and has made new management tooling available. These enhancements include an operational dashboard to monitor the health of your InfluxDB cluster, single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management APIs for tokens and databases.

Learn about the new v3 enhancements


InfluxDB Clustered general availability

InfluxDB Clustered is now generally available and gives you the power of InfluxDB v3 in your self-managed stack.

Talk to us about InfluxDB Clustered