0

I'm using the InfluxDB 2 client for Java, and I was wondering how I would check if the InfluxDB is online and if the given credentials are valid.

In influxdb-java I used the .ping() function, but I can't seem to find such a function for the influxdb-client-java

radmacher
  • 125
  • 2
  • 13

1 Answers1

0

There isn't an exact replacement for ping(), but you can use the REST endpoint /health instead. See: https://docs.influxdata.com/influxdb/v2.0/api/#operation/GetHealth

There is also a class you can use for this:

if (influxDb != null) {
    HealthCheck healthCheck = influxDb.health();
    if(healthCheck.getStatus() == StatusEnum.PASS) {
            // do what you want here
    }
}
abx-firez
  • 1
  • 1