IMD SolutionComputing LibraryShop main store

How-to

How InfluxDB remote replication works from an edge gateway

Edge computing and IIoT Published 7 min read

Short answer

Replication in InfluxDB 2.x is two objects created in order: a remote holding the destination URL, the remote organization's ID string and a write-scoped token, then a replication binding the local bucket to it. The stream forwards only writes made after it exists and never backfills; set the queue's size and age limits to survive your longest expected outage, then prove the path with one test point queried on the remote.

On this page
  1. The two objects and the order to create them
  2. Read what the streams already say
  3. Prepare the destination side
  4. Create the remote, then the stream
  5. Example: sizing the replication queue for a 60 h WAN outage
  6. Prove the path before production depends on it
  7. Replicate the downsampled bucket instead of the raw one
  8. Mistakes that cost a commissioning day
  9. Questions asked

The mirror is two InfluxDB objects created in a fixed order. First the remote: a stored connection holding the destination URL, the destination organization's ID string and an API token that can write to that one bucket. Then the replication: a stream binding the local bucket to a bucket on that remote, with its own on-disk queue. When the remote bucket stays empty, the cause is almost always one of three — the stream was never created, the token cannot write, or the organization name went into the ID field. Two limits decide what a WAN outage costs: the queue's size cap in bytes and its age cap, one week at defaults. The stream forwards only writes made after it exists and never copies history, so create it before production data flows, then prove it with one test point queried on the remote.

The two objects and the order to create them #

InfluxDB 2.x keeps the two halves separate on purpose. The remote is only a connection record, so it can be tested on its own; the replication is the stream, and it references the remote by the ID the create command returns. List what already exists with influx remote list and influx replication list before adding anything — the missing replication is the object people reinstall the whole application over. The order that works: destination bucket first, then a write-scoped token on it, then influx remote create, then influx replication create. The data also has to arrive in the local bucket before replication has anything to forward, which is the path storing MQTT data in InfluxDB with Telegraf sets up for MQTT-fed lines.

Read what the streams already say #

influx replication list is the cheapest test on the box and the first one to run. It shows every stream with the total size of its replication queue in bytes and the age limit the queue cleans against; if the CLI reports an error for a stream, that message names the cause before you change a setting. Match what you see against this table.

Symptom on the gateway Cause to fix
Data in the local bucket, nothing on the remote, no stream listed Only the remote exists; influx replication create never ran
Authorization error on the remote or the stream The token cannot write to that destination bucket, or the name sits in the ID field
Connection or TLS errors while the queue keeps growing The gateway cannot reach the remote: name resolution, route, outbound firewall, proxy, or an untrusted certificate
New points arrive on the remote, historical ones never do Expected behaviour — a stream starts at its creation and older points were never queued
The queue stops growing at its cap during a long outage The size or age cap cut the backlog; data beyond them never reaches the remote

Prepare the destination side #

On the far server, create the destination bucket, then issue an API token scoped to write on that bucket and nothing else: if the gateway is ever compromised, the leaked token can only add points to one bucket and can neither read nor delete anything. Copy the destination organization's ID string from the server's own interface — the display name is not the ID, and a name in the ID field produces an authorization failure that looks exactly like a bad token. Before touching the gateway, confirm the network path actually works: the destination URL resolves, the gateway has a route, the outbound firewall allows it, and the certificate is one the gateway trusts when the URL is HTTPS.

Create the remote, then the stream #

Work on the gateway that runs the source InfluxDB:

  1. Confirm the CLI generation. influx remote list should answer, even if only with an empty list; a 1.x-era binary rejects the command with flag provided but not defined: -org, which means the wrong CLI, not a broken server.
  2. Keep server profiles straight. The CLI stores its connections in ~/.influxdbv2/configs by default, --configs-path points elsewhere, -c, --active-config picks one, and --host with -o, --org overrides the local server and organization for a single command.
  3. Run influx remote create --help first: flag names move between releases, and your build defines what it accepts. Then create the remote — destination URL, destination organization ID string, write-scoped token. If the connection itself comes out wrong, remove it with influx remote delete and create it again rather than building streams on top of it.
  4. Create the stream with influx replication create, binding the local bucket to the destination bucket through that remote. Set the queue's size cap in bytes and the age limit with --max-age; the documented default is one week, and the purge loop only runs every 1 minute, so a point can sit slightly past its limit before removal.
  5. If the destination presents a certificate the gateway does not trust, --skip-verify is the documented switch that skips the TLS check — a bench-test shortcut only. In the plant, put the destination's certificate into the gateway's trust store; a skipped check accepts any server that answers on that address.
  6. Re-run influx remote list and influx replication list. Both objects exist, and the queue reads zero bytes until traffic flows.

Example: sizing the replication queue for a 60 h WAN outage #

Inputs: line protocol into the replicated bucket averages 100 kB/s and the WAN link is down for 60 h over a long weekend. Both are example figures — budget from your own measured rate, built from points per second and the per-point disk cost of Telegraf data (what one Telegraf point really costs on InfluxDB disk works that arithmetic), and measure rather than assume on a line that oversamples PLC tags (sizing an edge PC for oversampled PLC data covers that estimate). The documented limit in play is the age cap: one week (168 h) at defaults.

The rule: while the link is down, the queue grows at the write rate for every hour of the outage; the age cap, not the disk, bounds how long any point may wait.

100 kB/s × 3,600 s/h =   360,000 kB/h =  360 MB/h
360 MB/h × 60 h      = 21,600,000 kB  = 21.6 GB

Age check: 60 h sits under the 168 h default cap, so nothing expires during this outage and the size cap is the only limit that binds.

Result: the queue has to hold 21.6 GB, and the gateway disk has to have that much free.

Decision: set the stream's size cap above what the longest outage you intend to tolerate produces — for this line, 30 GB, about a third more than the 60 h case needs. An outage that runs past the age cap is decided by that cap, not by disk; while the link is down, watch the queue's byte figure climb in influx replication list and drain back toward zero after the link returns.

Prove the path before production depends on it #

  1. Write one test point into the local bucket under a measurement name nothing else uses.
  2. Query the destination bucket for that name. It should appear within seconds; if it does not, read the stream's error output before touching Flux or the collector.
  3. Cut the route to the remote — pull the WAN link or drop its firewall rule — write a few marked points, and watch the queue's size in bytes climb in influx replication list.
  4. Restore the route and watch the queue drain toward zero. The backlog should arrive on the remote, not disappear.
  5. If a downsample Task feeds the bucket you replicate, wait one full task interval and check the task's last run succeeded before blaming replication for a slow bucket.

Replicate the downsampled bucket instead of the raw one #

A scheduled Task on the source server can reduce every window to a mean and write the result into a second bucket; when the WAN link is slow or metered, replicate that second bucket and keep the raw one local. The choice is per bucket: raw crosses the network only when full fidelity matters, and replicating both doubles the traffic and the destination storage at the same time. Every bucket you mirror needs its own influx replication create — the stream follows the bucket you name, never a measurement inside it. This bucket-to-bucket mechanism also stops at the bucket boundary: historian-layer history moves differently, and replicating Ignition tag history into SQL Server works by adding articles to the database, a step you can automate.

Mistakes that cost a commissioning day #

  • Creating the stream after production data started — points written before the stream exists stay local; export and load them separately, and always create the stream first.
  • Mirroring the raw bucket when the Task's output was the plan — the Task's bucket needs its own stream.
  • A size cap larger than the gateway's free disk — a long outage then fills the disk the local database also lives on.
  • A retention period on the destination shorter than what you keep locally — the destination deletes replicated points on schedule and the stream looks broken.
  • Reinstalling the application or rewriting Flux first — the queue figure and the stream's error output name the cause in under a minute.

Questions asked

Can several replication streams share one remote connection?

Yes. The remote stores only the destination URL, the organization ID string and the token, so any number of streams can reference it. Each replication binds that remote to one local bucket and one destination bucket, and every stream keeps its own queue with its own size and age limits. Check each queue separately after an outage instead of assuming all of them drained together.

Which data does an outage past the age limit lose?

The oldest points first. The queue purge runs every minute and removes anything older than the stream's age limit before it is delivered, so at the default one-week setting the remote keeps roughly the newest week and loses everything earlier, even though those points still sit on the gateway disk. Raising the limit only helps if the size cap and the disk can hold the extra days.

Does replication work between InfluxDB 1.x servers?

No. Remotes and replications are InfluxDB 2.x features, and both ends need that model: the destination must accept 2.x writes into a bucket, and the CLI must be the 2.x build, because a 1.x-era binary rejects the replication commands with a flag-not-defined error. To feed a 1.x server, either upgrade the destination or write your own small forwarder against its write interface.

How long should the destination bucket's retention be?

At least as long as the local bucket keeps data, and longer if dashboards or reports read history from the remote. A short retention on the destination deletes replicated points on schedule, which looks exactly like a broken stream: the queue drains cleanly while trend data disappears. If the destination is meant to be the long-term copy, give it no retention period at all.

Do replicated points keep their original timestamps?

Yes. The stream forwards each batch through the destination's write interface with the timestamps the points already carry, so data written during an outage lands in its correct place on the trend once the link recovers. Prove it deliberately on commissioning: pull the link, write a few marked points, restore it, and check they appear at their original times, not at the recovery time.

Keep reading

  • Troubleshooting

    Edge tags unreachable after a PC replacement

    Keep the remote tag provider as it is. After an Edge PC replacement, the SecurityException on provider access traced to the MQTT Transmission module, whose entitlement did not survive the backup, license transfer and restore; reinstalling the module restored browsing from the central gateway. Confirm zones and tag-access policy first, then check module licensing before touching the provider.

    Edge computing and IIoT

  • Troubleshooting

    Node-RED writes to InfluxDB on another PC time out

    The write is an HTTP request to TCP 8086, and a successful ping proves only ICMP reachability. In the reported case the PC's firewall dropped the InfluxDB inbound rule on the Public profile; enabling it restored the writes. Diagnose the gateway-to-PC hop on its own and confirm which URL field the node actually dials.

    Edge computing and IIoT

  • Troubleshooting

    Remote tag history stops when gateway redundancy fails

    A running Gateway Network connection proves the transport, not the services behind it. In the reported case the redundant pair hosting the history providers had detected thread deadlocks on the backup and a disconnected redundancy peer on the primary after a direct upgrade to 8.3.4, so gateway and redundancy health must be restored before any remote provider is reconfigured.

    Edge computing and IIoT