Yes, you are correct that disk stats can be obtained using the _nodes/stats
API as REST high-level client doesn't provide any direct API for node stats, you can see all the API supported by it here.
But you can use the low level rest client which is provide in high level client and below is the working example code.
private void getDiskStats(RestHighLevelClient restHighLevelClient) throws IOException {
RestClient lowLevelClient = restHighLevelClient.getLowLevelClient();
Request request = new Request(
"GET",
"/_nodes/stats");
Response response = lowLevelClient.performRequest(request);
if (response.getStatusLine().getStatusCode() == 200) {
System.out.println("resp: \n"+ EntityUtils.toString(response.getEntity()));
}
}
You can see I am printing the O/P of above API on console and verified that it contains the disk usage status which comes in below format:
"most_usage_estimate": {
"path": "/home/opster/runtime/elastic/elasticsearch-7.8.1/data/nodes/0",
"total_in_bytes": 124959473664,
"available_in_bytes": 6933352448,
"used_disk_percent": 94.45151916481107
},