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
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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.