use of org.graylog2.system.stats.elasticsearch.ShardStats in project graylog2-server by Graylog2.
the class Cluster method elasticsearchStats.
public ElasticsearchStats elasticsearchStats() {
final List<String> indices = Arrays.asList(indexSetRegistry.getIndexWildcards());
final org.graylog2.system.stats.elasticsearch.ClusterStats clusterStats = clusterAdapter.clusterStats();
final PendingTasksStats pendingTasksStats = clusterAdapter.pendingTasks();
final ShardStats shardStats = clusterAdapter.shardStats(indices);
final org.graylog2.system.stats.elasticsearch.ClusterHealth clusterHealth = org.graylog2.system.stats.elasticsearch.ClusterHealth.from(shardStats, pendingTasksStats);
final HealthStatus healthStatus = clusterAdapter.health(indices).orElseThrow(() -> new IllegalStateException("Unable to retrieve cluster health."));
return ElasticsearchStats.create(clusterStats.clusterName(), clusterStats.clusterVersion(), healthStatus, clusterHealth, clusterStats.nodesStats(), clusterStats.indicesStats());
}
use of org.graylog2.system.stats.elasticsearch.ShardStats in project graylog2-server by Graylog2.
the class ClusterAdapterES6 method shardStats.
@Override
public ShardStats shardStats(Collection<String> indices) {
final Health clusterHealthRequest = new Health.Builder().addIndex(indices).build();
final JestResult clusterHealthResponse = JestUtils.execute(jestClient, clusterHealthRequest, () -> "Couldn't read Elasticsearch cluster health");
final JsonNode clusterHealthJson = clusterHealthResponse.getJsonObject();
return ShardStats.create(clusterHealthJson.path("number_of_nodes").asInt(-1), clusterHealthJson.path("number_of_data_nodes").asInt(-1), clusterHealthJson.path("active_shards").asInt(-1), clusterHealthJson.path("relocating_shards").asInt(-1), clusterHealthJson.path("active_primary_shards").asInt(-1), clusterHealthJson.path("initializing_shards").asInt(-1), clusterHealthJson.path("unassigned_shards").asInt(-1), clusterHealthJson.path("timed_out").asBoolean());
}
Aggregations