How to replicate a read only database

I have (only) read access to a 2.x instance on the inverter of a PV system. I would like to periodically read data from the inverter database using a Raspberry PI (4B) with its own InfluxDB instance.
The way I (as a newbie) understand replication, it can only “send” from the source to a target. However, I need the reverse direction, i.e. “receiving” in the target from the source.

(How) does that work?

@kho Just create a task on your RPi InfluxDB instance that queries all the data written to your read-only instance since the last task interval and writes it to your RPi instance:

import "influxdata/influxdb/tasks"

option task = {
    name: "Replicate data from inverter",
    every: 5m

    org: "PV_ORG_NAME",
    token: "READ_ONLY_API_TOKEN",
    |> range(start: tasks.lastSuccess(orTime: 2020-01-01T00:00:00Z)
    |> to(bucket: "YOUR_LOCAL_BUCKET_NAME")

Hi @kho. To use the replication feature, you would need an API token from the source instance that has permission to create a replication. It sounds like you don’t have that permission.
Otherwise, if you have read permission on the source instance, you can query the data from the source, as @scott described (he just beat me to the punch).

Hi @scott,

first of all: Thanks for the task code (btw: one “)” was missing in the range line)

The task end with this error message:
2024-06-20 21:52:45 Started task from script: "import "influxdata/influxdb/tasks"\noption task = { \n name: …
2024-06-20 21:52:45 Completed(failed)
2024-06-20 21:52:45 could not execute task run: unexpected end of JSON input

What’s going wrong?

Nice catch. Sorry about that.

Did you save the task through the UI? The UI does some funky stuff with the task option (setting the name and interval) when you create a brand new task using the UI. Double check the task code and make sure it didn’t get updated on save.

Yes, I did it through the UI.
I don’t know any other way yet (as an Infux newbie).

Ok, try running just the following in the data explorer, just to make sure the request is actually working:

    org: "PV_ORG_NAME",
    token: "READ_ONLY_API_TOKEN",
    |> range(start: -10m)

Query doesn’t run:

An internal error has occurred - check server logs

I don’t know how to find the logs on the inverter instance.
Or is ‘server’ here the local InfluxDB?

Hi scott,

I have to call it a night, it’s almost midnight here.

No worries. Just double check the InfluxDB host, org, and token in from. I’m wondering if it’s failing to authorize and just isn’t propagating back to the function call.

Hi @scott,
Thanks for your help so far!
I will take care of the server logs next and maybe contact the manufacturer of the solar system.

But for now I’m offline until the end of the month.
I’ll get back to you in July.