Write data from InfluxDB OSS to InfluxDB Cloud
Replicate writes to InfluxDB OSS to InfluxDB Cloud
To replicate all writes to an InfluxDB OSS instance to an InfluxDB Cloud instance, use InfluxDB replication streams.
InfluxDB Cloud rate limits
Write requests to InfluxDB Cloud are subject to the rate limits associated with your InfluxDB Cloud pricing plan.
Query data from InfluxDB OSS.
(Optional) or process data to write to InfluxDB Cloud.
-
Use the following guidelines:
to(): Use to write data in field keys to the
_field
column and field values to the_value
column.experimental.to(): Use to write data in column names to corresponding field keys and column values to field values.
-
- bucket: InfluxDB Cloud bucket to write to
- host: InfluxDB Cloud region URL
- org: InfluxDB Cloud organization
- token: InfluxDB Cloud API Token
import "experimental"
import "influxdata/influxdb/secrets"
cloudToken = secrets.get(key: "INFLUX_CLOUD_API_TOKEN")
from(bucket: "example-oss-bucket")
|> range(start: -10m)
|> filter(fn: (r) => r._measurement == "example-measurement")
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
|> experimental.to(
bucket: "example-cloud-bucket",
host: "https://cloud2.influxdata.com",
token: cloudToken,
)
to()
requires_time
,_measurement
,_field
, and_value
columns.to()
writes all other columns as tags where the column name is the tag key and the column value is the tag value.
Input data
Output line protocol
experimental.to()
requires_time
and_measurement
columns.- Columns in the (other than
_measurement
) are parsed as tags where the column name is the tag key and the column value is the tag value. - Columns not in the group key (other than
_time_
) are parsed as fields where the column name is the field key and the column value is the field value.
Input data
Group key = [_measurement, exampleTag]
Output line protocol
example-m,exampleTag=A temp=80.0,rpm=4023i 1609459200000000000
example-m,exampleTag=A temp=81.1,rpm=4901i 1609459320000000000
Downsample and write data to InfluxDB Cloud
Write min, max, and mean values to InfluxDB Cloud
import "influxdata/influxdb/secrets"
cloudToken = secrets.get(key: "INFLUX_CLOUD_API_TOKEN")
data = from(bucket: "example-oss-bucket")
|> range(start: -30m)
|> filter(fn: (r) => r._measurement == "example-measurement")
min = data |> aggregateWindow(every: 10m, fn: min) |> map(fn: (r) => ({ r with _field: "{$r._field}_min" }))
max = data |> aggregateWindow(every: 10m, fn: max) |> map(fn: (r) => ({ r with _field: "{$r._field}_max" }))
mean = data |> aggregateWindow(every: 10m, fn: mean) |> map(fn: (r) => ({ r with _field: "{$r._field}_mean" }))
union(tables: [min, max, mean])
|> to(
bucket: "example-cloud-bucket",
host: "https://cloud2.influxdata.com",
org: "example-org",
token: cloudToken,
To automatically and routinely write data from InfluxDB OSS to InfluxDB Cloud, create a task in your InfluxDB OSS instance that regularly queries, processes, and writes data to InfluxDB Cloud.