influxdata / influxdb-client-java

InfluxDB 2 JVM Based Clients
https://influxdata.github.io/influxdb-client-java/
MIT License
430 stars 129 forks source link

Can I monitor influxdb through API, or the monitoring interface exposed to the outside world? #693

Closed ZY945 closed 5 months ago

ZY945 commented 5 months ago

I want to get some monitoring indicators of the influxdb database

bednar commented 5 months ago

Hi @ZY945,

Thank you for utilizing our client for your InfluxDB interactions.

To check the status of your InfluxDB instance, you can leverage the ping method provided by the client. This method will allow you to programmatically assess the health and availability of the InfluxDB service.

Here's a quick example of how you can use this method:

try (InfluxDBClient client = InfluxDBClientFactory.create("http://localhost:8086", "my-token".toCharArray())) {
            Boolean isReachable = client.ping();
            System.out.println("InfluxDB isReachable: " + isReachable);
}

This will give you a straightforward indication of the InfluxDB's current state, which can be particularly useful for monitoring and operational checks.

If you have any further questions or need additional assistance, please don't hesitate to reach out.

Best Regards.