Hi there! I’m currently using influxdb to persist time series data. Now I’m planning to store some data related to a specific project and I thought it would be a great idea to use a different database name for that (still on the same influxdb server). This new database might grow large so I want to keep it separate from my current. Obviously I haven’t been able to search and find a solution for how to configure my openHAB 3.4.2 instance to use multiple influxdb databases so I’m asking you guys. I appreciate your kind help.
AFAIK persistence services are singular hence their configuration apply to whole openHAB. You may need to employ another persistence service.
Yes, persistence is one per service, you can’t use more than one InfluxDB at the same time.
On the other hand, with InfluxDB2.6.1 there might be options to split the data depending on keys and tags (I’m not deep into this rabbit hole yet)..
Thanks guys for the information!
I found a pretty simple solution using nginx: Module ngx_http_mirror_module
My (abbreviated) configuration looks like this:
server {
listen 443 ssl;
server_name influx.internal;
include snippets/acme.conf;
location / {
mirror /mirror;
proxy_pass http://192.168.2.5:8086; # influxdb
}
location = /mirror {
internal;
proxy_pass http://192.168.2.43:8428/write; # victoriametrics using influxdb format for ingest
}
}
How is it possible to mirror to a second influxdb? The first one with read and write, having a short retention period for performance reasons. The second one for long term archiving, w/o retention. Read queries should not be mirrored to the archive (performance, anyhow discarded).
Does my solution in my comment above not work for you?
I would expect, that it also forwards all read queries to the second DB (influx, w/o unlimited retention period in my case). Second DB will execute the query, the system suffers from the load while the result is anyhow ignored via the proxy.
Then just use the host configured with mirroring for ingest and not for read requests. That’s how I do it.
K. I could configure 2 servers in openHAB: The mirror for all write operations. And the direct connection to the first one for all read operations incl. restoreOnStartup
Edit: multiple instances of the same database are not possible in openHAB.
I bet you could even do some splitting magic in nginx to separate the GET and POST requests
Jup, that should work as according to API Reference | InfluxData Documentation Archive there are 3 different endpoints for API v1 as well as several for API v2 https://docs.influxdata.com/influxdb/v2/api-guide/:
server {
listen 443 ssl;
server_name influx.internal;
include snippets/acme.conf;
location /write { # v1 write enpoint
mirror /mirrorVM;
mirror /mirrorInflux;
proxy_pass http://192.168.2.5:8086$request_uri; # influxdb
}
location /api/v2/write { # v2 write endpoint
mirror /mirrorVM;
mirror /mirrorInflux;
proxy_pass http://192.168.2.5:8086$request_uri; # influxdb
}
location / { # all other endpoints
proxy_pass http://192.168.2.5:8086$request_uri; # influxdb
}
location = /mirrorVM {
internal;
proxy_pass http://192.168.2.40:8428/write; # victoriametrics using influxdb format for ingest
}
location = /mirrorInflux {
internal;
proxy_pass http://192.168.2.50:8090$request_uri; # influx backup, v1 or v2 endpoint depending on request_uri
}
}
how-to-send-data-in-influxdb-v2-format specifies also an InfluxDB v2 endpoint for VictoriaMetrics.
Thereby the mirror shall look as follows:
location = /mirrorVM {
internal;
proxy_pass http://192.168.2.40:8428$request_uri; # victoriametrics using influxdb format for ingest
}