openwisp-monitoring icon indicating copy to clipboard operation
openwisp-monitoring copied to clipboard

[change] Add support for influxdb 2.0

Open nemesifier opened this issue 4 years ago • 10 comments

I had to pin the inflxudb docker image used for testing to version 1.8.4 because the new version 2.0 breaks the tests: https://github.com/openwisp/openwisp-monitoring/pull/273

However, this is not great: we want to test with the latest influxdb version and therefore it would be great to upgrade our code so that the test environment is compatible with the last influxdb version. It should be just a matter of setting the authentication credentials correctly.

I think we have to write a new timeseries backend for Influxdb > 2.0 and keep the current backend for Influxdb <= 1.8.

nemesifier avatar Mar 10 '21 23:03 nemesifier

Hi @nemesisdesign the current library used here supports InfluxDB 1.x only. Another library (influxdb-client) only support InfluxDB 1.8+.

Would it be good to drop support for InfluxDB 1.7 or earlier ? :thinking:

devkapilbansal avatar Apr 09 '21 15:04 devkapilbansal

Hi @nemesisdesign the current library used here supports InfluxDB 1.x only. Another library (influxdb-client) only support InfluxDB 1.8+.

Would it be good to drop support for InfluxDB 1.7 or earlier ?

@devkapilbansal I guess we have no other viable option, influxdb 1.8 works well so if we can support from 1.8 onwards that's good enough, what worries me is the change of library, do you know if the syntax is similar?

nemesifier avatar Apr 09 '21 17:04 nemesifier

Yes, as both libraries are maintained by InfluxData, syntax is quite similar

devkapilbansal avatar Apr 09 '21 18:04 devkapilbansal

@nemesisdesign I cannot reproduce this issue. I changed the version of influxdb image to 2.0-alpine in both docker-compose.yml and workflows/ci.yml. All the tests run perfectly.

AbhigyaShridhar avatar Mar 22 '22 18:03 AbhigyaShridhar

@AbhigyaShridhar how did you checked it? I just checked and issue is reproducible: https://github.com/devkapilbansal/openwisp-monitoring/runs/5649166266?check_suite_focus=true#step:10:17

Had it not been reproducible, the version have been updated a long time ago

devkapilbansal avatar Mar 22 '22 18:03 devkapilbansal

@devkapilbansal I ran ./run-qa-checks and ./runtests.py on my local system.

AbhigyaShridhar avatar Mar 22 '22 19:03 AbhigyaShridhar

@nemesisdesign I cannot reproduce this issue. I changed the version of influxdb image to 2.0-alpine in both docker-compose.yml and workflows/ci.yml. All the tests run perfectly.

I wish it was so simple @AbhigyaShridhar, last time we checked, in order to use Influxdb 2.0, we would have to switch to a different python library, please read the first lines of https://github.com/influxdata/influxdb-python#influxdb-python for more info.

nemesifier avatar Mar 22 '22 23:03 nemesifier

@nemesisdesign I cannot reproduce this issue. I changed the version of influxdb image to 2.0-alpine in both docker-compose.yml and workflows/ci.yml. All the tests run perfectly.

I wish it was so simple @AbhigyaShridhar, last time we checked, in order to use Influxdb 2.0, we would have to switch to a different python library, please read the first lines of https://github.com/influxdata/influxdb-python#influxdb-python for more info.

Oh, ok I'll look into that

AbhigyaShridhar avatar Mar 23 '22 04:03 AbhigyaShridhar

One announcement which is surely going to impact this work: https://www.influxdata.com/blog/influxdb-engine/

nemesifier avatar Oct 28 '22 13:10 nemesifier

In case anyone else wants to try it, there is an ugly way to get it up and running with InfluxDB 2 and the 1.x compatibility API. I used an NGINX reverse-proxy that filters out the incompatible API requests coming from OpenWISP monitoring. Of course, this means that you need to set up the retention policy mapping to buckets yourself.

The following NGINX configuration filters requests and inserts an InfluxDB v2 API token:

server {
    listen       8086;
    listen  [::]:8086;
    server_name  influxdb;

    location / {
        proxy_pass https://0.0.0.0;
        proxy_ssl_verify on;
        proxy_ssl_name influxdb.example.com;
        proxy_ssl_server_name on;
        proxy_set_header influxdb.example.com;
        proxy_set_header Authorization "Token changeme";
        client_body_buffer_size 128K;

        if ($arg_q ~ "^CREATE\+DATABASE") {
                return 200 '{}';
        }
        if ($arg_q ~ "^CREATE\+RETENTION") {
                return 200 '{}';
        }
        if ($arg_q ~ "^ALTER\+RETENTION") {
                return 200 '{}';
        }
        if ($arg_q ~ "^SHOW\+RETENTION") {
                return 200 '{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["autogen", "0s", "0s", 1, true], ["short", "0s", "0s", 1, false]]}]}]}';
        }
    }
}

Kevinjil avatar Oct 16 '23 11:10 Kevinjil