Search in sources :

Example 1 with Stats

use of io.searchbox.indices.Stats in project graylog2-server by Graylog2.

the class IndicesAdapterES6 method indexStatsWithShardLevel.

private JsonNode indexStatsWithShardLevel(final String indexName) {
    final Stats request = new Stats.Builder().addIndex(indexName).setParameter("level", "shards").ignoreUnavailable(true).build();
    final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Couldn't check stats of index " + indexName);
    return jestResult.getJsonObject().path("indices").path(indexName);
}
Also used : FieldSortBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.sort.FieldSortBuilder) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder) FilterAggregationBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder) IndexRangeStats(org.graylog2.indexer.searches.IndexRangeStats) Stats(io.searchbox.indices.Stats) JestResult(io.searchbox.client.JestResult)

Example 2 with Stats

use of io.searchbox.indices.Stats in project graylog2-server by Graylog2.

the class IndicesAdapterES6 method storeSizeInBytes.

@Override
public Optional<Long> storeSizeInBytes(String index) {
    final Stats request = new Stats.Builder().addIndex(index).store(true).build();
    final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Couldn't check store stats of index " + index);
    final JsonNode sizeInBytes = jestResult.getJsonObject().path("indices").path(index).path("primaries").path("store").path("size_in_bytes");
    return Optional.of(sizeInBytes).filter(JsonNode::isNumber).map(JsonNode::asLong);
}
Also used : IndexRangeStats(org.graylog2.indexer.searches.IndexRangeStats) Stats(io.searchbox.indices.Stats) JsonNode(com.fasterxml.jackson.databind.JsonNode) JestResult(io.searchbox.client.JestResult)

Example 3 with Stats

use of io.searchbox.indices.Stats in project graylog2-server by Graylog2.

the class IndicesAdapterES6 method getAllWithShardLevel.

private JsonNode getAllWithShardLevel(final Collection<String> indices) {
    final Stats request = new Stats.Builder().addIndex(indices).setParameter("level", "shards").build();
    final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Couldn't fetch index stats of indices " + indices);
    final JsonNode responseJson = jestResult.getJsonObject();
    final int failedShards = responseJson.path("_shards").path("failed").asInt();
    if (failedShards > 0) {
        throw new ElasticsearchException("Index stats response contains failed shards, response is incomplete");
    }
    return responseJson.path("indices");
}
Also used : IndexRangeStats(org.graylog2.indexer.searches.IndexRangeStats) Stats(io.searchbox.indices.Stats) JsonNode(com.fasterxml.jackson.databind.JsonNode) ElasticsearchException(org.graylog2.indexer.ElasticsearchException) JestResult(io.searchbox.client.JestResult)

Example 4 with Stats

use of io.searchbox.indices.Stats in project graylog2-server by Graylog2.

the class IndicesAdapterES6 method getIndexStats.

@Override
public JsonNode getIndexStats(final Collection<String> indices) {
    final Stats request = new Stats.Builder().addIndex(indices).docs(true).store(true).build();
    final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Couldn't check stats of indices " + indices);
    return jestResult.getJsonObject().path("indices");
}
Also used : FieldSortBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.sort.FieldSortBuilder) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder) FilterAggregationBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder) IndexRangeStats(org.graylog2.indexer.searches.IndexRangeStats) Stats(io.searchbox.indices.Stats) JestResult(io.searchbox.client.JestResult)

Example 5 with Stats

use of io.searchbox.indices.Stats in project graylog2-server by Graylog2.

the class IndicesAdapterES6 method indexStats.

private JsonNode indexStats(final String indexName) {
    final Stats request = new Stats.Builder().addIndex(indexName).build();
    final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Couldn't check stats of index " + indexName);
    return jestResult.getJsonObject().path("indices").path(indexName);
}
Also used : FieldSortBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.sort.FieldSortBuilder) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder) FilterAggregationBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder) IndexRangeStats(org.graylog2.indexer.searches.IndexRangeStats) Stats(io.searchbox.indices.Stats) JestResult(io.searchbox.client.JestResult)

Aggregations

JestResult (io.searchbox.client.JestResult)5 Stats (io.searchbox.indices.Stats)5 IndexRangeStats (org.graylog2.indexer.searches.IndexRangeStats)5 FilterAggregationBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder)3 SearchSourceBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder)3 FieldSortBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.search.sort.FieldSortBuilder)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ElasticsearchException (org.graylog2.indexer.ElasticsearchException)1