centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 273 forks source link

[database::influxdb::plugin] Is InfluxDB v2 supported? #5037

Open Aleksey-Maksimov opened 3 months ago

Aleksey-Maksimov commented 3 months ago

Hello. Is InfluxDB v2 supported in the plugin "database::influxdb::plugin" ?

# ./centreon_plugins.pl --plugin=database::influxdb::plugin --mode=list-databases 
--hostname localhost --username 'admin' --password 'mypass' --debug

UNKNOWN: 401 Unauthorized

URL: 'http://localhost:8086/query?epoch=s'
Parameters: 'q=SHOW DATABASES'
======> request send
POST http://localhost:8086/query?epoch=s
Authorization: Basic aWNpbm....==
User-Agent: centreon::plugins::backend::http::useragent
Content-Type: application/x-www-form-urlencoded

q=SHOW+DATABASES
======> response done
HTTP/1.1 401 Unauthorized
Date: Wed, 22 May 2024 20:41:31 GMT
Content-Length: 48
Content-Type: application/json; charset=utf-8
Client-Date: Wed, 22 May 2024 20:41:31 GMT
Client-Peer: 127.0.0.1:8086
Client-Response-Num: 1
X-Influxdb-Build: OSS
X-Influxdb-Version: v2.7.6
X-Platform-Error-Code: unauthorized

{"code":"unauthorized","message":"Unauthorized"}
lucie-dubrunfaut commented 1 month ago

Hello :)

Were you able to verify via a curl command that you were able to authenticate? Were you able to verify that you were able to query the path: http://localhost:8086/query?epoch=s?

Aleksey-Maksimov commented 1 month ago

I think username and password are not enough for InfluxDB v2. As far as I understand, it uses an access token to connect to the InfluxDB v2 API, but "database::influxdb::plugin" does not have options to pass the token.

lucie-dubrunfaut commented 1 month ago

Ok if I well understand the api.pm custom mode needs an update with a token handling to ensure compatibility with InfluxDB v2? If so, can you provide us the API doc/endpoint that would ensure authentication with a token rather than a combination of username and password?

Aleksey-Maksimov commented 1 month ago

Official API documentation here https://docs.influxdata.com/influxdb/v2/api/

lucie-dubrunfaut commented 1 month ago

Hello :)

First thanks for the documentation link. And to facilitate the addition of token authentication in the plugin, can you provide us the curl commands and JSON returns which may allow us to simulate your connection environment (and why not test list-database mode)?

Aleksey-Maksimov commented 1 month ago

I don't understand what "curl commands" you are talking about.

lucie-dubrunfaut commented 1 month ago

I think I found what I was looking for in the TokenAuthentication section.