Search in sources :

Example 1 with ShardStats

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());
}
Also used : ShardStats(org.graylog2.system.stats.elasticsearch.ShardStats) HealthStatus(org.graylog2.indexer.indices.HealthStatus)

Example 2 with ShardStats

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());
}
Also used : ClusterHealth(org.graylog2.rest.models.system.indexer.responses.ClusterHealth) Health(io.searchbox.cluster.Health) JsonNode(com.fasterxml.jackson.databind.JsonNode) JestResult(io.searchbox.client.JestResult)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 JestResult (io.searchbox.client.JestResult)1 Health (io.searchbox.cluster.Health)1 HealthStatus (org.graylog2.indexer.indices.HealthStatus)1 ClusterHealth (org.graylog2.rest.models.system.indexer.responses.ClusterHealth)1 ShardStats (org.graylog2.system.stats.elasticsearch.ShardStats)1