use of org.sonar.server.es.response.IndicesStatsResponse in project sonarqube by SonarSource.
the class EsClient method indicesStats.
// https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html
public IndicesStatsResponse indicesStats(String... indices) {
return execute(() -> {
Request request = new Request("GET", "/" + (indices.length > 0 ? (String.join(",", indices) + "/") : "") + "_stats");
request.addParameter("level", "shards");
Response response = restHighLevelClient.getLowLevelClient().performRequest(request);
return IndicesStatsResponse.toIndicesStatsResponse(gson.fromJson(EntityUtils.toString(response.getEntity()), JsonObject.class));
}, () -> computeDetailsAsString(indices));
}
use of org.sonar.server.es.response.IndicesStatsResponse in project sonarqube by SonarSource.
the class EsIndexesSection method completeIndexAttributes.
private void completeIndexAttributes(ProtobufSystemInfo.Section.Builder protobuf) {
IndicesStatsResponse indicesStats = esClient.indicesStats();
for (IndexStats indexStats : indicesStats.getAllIndexStats()) {
String prefix = "Index " + indexStats.getName() + " - ";
setAttribute(protobuf, prefix + "Docs", indexStats.getDocCount());
setAttribute(protobuf, prefix + "Shards", indexStats.getShardsCount());
setAttribute(protobuf, prefix + "Store Size", humanReadableByteCountSI(indexStats.getStoreSizeBytes()));
}
}
Aggregations