content/shared/influxdb-v2/write-data/replication/replicate-data.md
Use InfluxDB replication streams (InfluxDB Edge Data Replication) to replicate the incoming data of select buckets to one or more buckets on a remote InfluxDB OSS, InfluxDB Cloud, or InfluxDB Enterprise v1 instance.
Replicate data from InfluxDB OSS to InfluxDB Cloud, InfluxDB OSS, or InfluxDB Enterprise v1.
Use the influx CLI or the
InfluxDB {{< current-version >}} API to configure
a replication stream.
[!Note] To replicate data to InfluxDB OSS or InfluxDB Enterprise v1, adjust the remote connection values accordingly.
{{< tabs-wrapper >}} {{% tabs %}} CLI API {{% /tabs %}} {{% tab-content %}}
<!--------------------------------- BEGIN CLI --------------------------------->In your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS instance, use
the influx remote create command and provide the following arguments for the remote instance:
{{% show-in "v2" %}}
influx remote create \
--name example-remote-name \
--remote-url https://cloud2.influxdata.com \
--remote-api-token mYsuP3r5Ecr37t0k3n \
--remote-org-id 00xoXXoxXX00
Alternatively, you can use an existing connection that you have already configured.
To retrieve existing connections, run influx remote list.
In your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS instance, use the
influx replication create command and provide the following arguments:
{{% show-in "v2" %}}
db-name/rp-name bucket name syntax.{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}influx replication create \
--name REPLICATION_STREAM_NAME \
--remote-id REPLICATION_REMOTE_ID \
--local-bucket-id INFLUX_BUCKET_ID \
--remote-bucket REMOTE_INFLUX_BUCKET_NAME
After you create the replication stream, InfluxDB {{% show-in "v2" %}}OSS{{% /show-in %}}
replicates all writes to the specified local bucket to the {{% show-in "v2" %}}remote {{% /show-in %}}
InfluxDB {{% show-in "cloud,cloud-serverless" %}}Cloud {{% /show-in %}}bucket.
Use the influx replication list command to view information such as the current queue size,
max queue size, and latest status code.
{{% /tab-content %}} {{% tab-content %}}
<!--------------------------------- BEGIN API --------------------------------->To create a remote connection to replicate data to,
send a POST request to your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS /api/v2/remotes endpoint:
{{< keep-url >}} {{< api-endpoint endpoint="localhost:8086/api/v2/remotes" method="POST" api-ref="/influxdb/version/api/#operation/PostRemoteConnection" >}}
Include the following parameters in your request:
POSTToken scheme with your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS API tokenapplication/json
{{% show-in "v2" %}}{{< keep-url >}}
curl --request POST http://localhost:8086/api/v2/remotes \
--header 'Authorization: Token INFLUX_OSS_TOKEN' \
--data '{
"allowInsecureTLS": false,
"description": "Example remote description",
"name": "Example remote name",
"orgID": "INFLUX_OSS_ORG_ID",
"remoteAPIToken": "REMOTE_INFLUX_TOKEN",
"remoteOrgID": "REMOTE_INFLUX_ORG_ID",
"remoteURL": "https://cloud2.influxdata.com"
}'
Alternatively, you can use an
existing connection that you have already configured.
To retrieve existing connections, use the /api/v2/remotes
endpoint with the GET request method:
{{< keep-url >}} {{< api-endpoint endpoint="localhost:8086/api/v2/remotes" method="GET" api-ref="/influxdb/version/api/#operation/GetRemoteConnections" >}}
Include the following parameters in your request:
Token scheme with your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS API token{{< keep-url >}}
curl --request GET \
http://localhost:8086/api/v2/remotes?orgID=INFLUX_OSS_ORG_ID \
--header 'Authorization: Token INFLUX_OSS_TOKEN' \
Send a POST request to your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS
/api/v2/replications endpoint to create a replication stream.
{{< keep-url >}} {{< api-endpoint endpoint="localhost:8086/api/v2/remotes" method="POST" api-ref="/influxdb/version/api/#operation/PostRemoteConnection" >}}
Include the following parameters in your request:
Token scheme with your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS API tokenapplication/json
{{% show-in "v2" %}}604800, must be greater than or equal to 0).67108860, must be greater than or equal to 33554430).db-name/rp-name bucket name syntax.
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}604800, must be greater than or equal to 0)67108860, must be greater than or equal to 33554430)remoteBucketName)remoteBucketID)[!Note]
remoteBucketIDandremoteBucketNameare mutually exclusive. {{% show-in "v2" %}}If replicating to InfluxDB Enterprise v1, useremoteBucketNamewith thedb-name/rp-namebucket name syntax.{{% /show-in %}}
{{< keep-url >}}
curl --request POST http://localhost:8086/api/v2/replications \
--header 'Authorization: Token INFLUX_OSS_TOKEN' \
--data '{
"dropNonRetryableData": false,
"localBucketID": "INFLUX_OSS_BUCKET_ID",
"maxAgeSeconds": 604800,
"maxQueueSizeBytes": 67108860,
"name": "Example replication stream name",
"orgID": "INFLUX_OSS_ORG_ID",
"remoteBucketName": "REMOTE_INFLUX_BUCKET_NAME",
"remoteID": "REMOTE_ID",
}'
After you create a replication stream, InfluxDB {{% show-in "v2" %}}OSS{{% /show-in %}}
replicates all writes from the specified local bucket to the {{% show-in "v2" %}}remote {{% /show-in %}}
InfluxDB {{% show-in "cloud,cloud-serverless" %}}Cloud {{% /show-in %}}bucket.
To get
information such as the current queue size, max queue size, and latest status
code for each replication stream, send a GET request to your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS /api/v2/replications endpoint:
{{< keep-url >}} {{< api-endpoint endpoint="localhost:8086/api/v2/replications" method="GET" api-ref="/influxdb/version/api/#operation/GetReplications" >}}
Include the following parameters in your request:
Token scheme with your {{% show-in "v2" %}}local{{% /show-in %}} InfluxDB OSS API token{{< keep-url >}}
curl --request GET \
http://localhost:8086/api/v2/replications?orgID=INFLUX_OSS_ORG_ID \
--header 'Authorization: Token INFLUX_OSS_TOKEN' \
{{% /tab-content %}} {{< /tabs-wrapper >}}
{{% note %}}
In some cases, you may not want to write raw, high-precision data to a remote InfluxDB {{% show-in "cloud,cloud-serverless" %}}Cloud {{% /show-in %}} instance. To replicate only downsampled or processed data:
Create a bucket in your InfluxDB OSS instance to store downsampled or processed data in.
Create an InfluxDB task that downsamples or processes data and stores it in the new bucket. For example:
import "influxdata/influxdb/tasks"
import "types"
// omit this line if adding task via the UI
option task = {name: "Downsample raw data", every: 10m}
data = () => from(bucket: "example-bucket")
|> range(start: tasks.lastSuccess(orTime: -task.every))
numeric = data()
|> filter(fn: (r) => types.isType(v: r._value, type: "float") or types.isType(v: r._value, type: "int") or types.isType(v: r._value, type: "uint"))
|> aggregateWindow(every: task.every, fn: mean)
nonNumeric = data()
|> filter(fn: (r) => types.isType(v: r._value, type: "string") or types.isType(v: r._value, type: "bool"))
|> aggregateWindow(every: task.every, fn: last)
union(tables: [numeric, nonNumeric])
|> to(bucket: "example-downsampled-bucket")
Create a replication stream to replicate data from the downsampled bucket to the remote InfluxDB {{% show-in "cloud,cloud-serverless" %}}Cloud {{% /show-in %}}instance.
In addition to replication stream information that you can access using the CLI or API, you can view replication service-level metrics for your InfluxDB OSS instance, such as /api/v2/write error details, the number and duration of calls to the service, and the total number of points queued.
To view replication service-level metrics send a GET request to your local InfluxDB OSS /metrics endpoint.
For more information, see InfluxDB OSS metrics.