Search in sources :

Example 6 with IndexStatistics

use of org.graylog2.indexer.indices.stats.IndexStatistics in project graylog2-server by Graylog2.

the class IndicesResource method getOpenIndicesInfo.

private OpenIndicesInfo getOpenIndicesInfo(Set<IndexStatistics> indicesStatistics) {
    final Map<String, IndexInfo> indexInfos = new HashMap<>();
    final Set<String> indices = indicesStatistics.stream().map(IndexStatistics::index).collect(Collectors.toSet());
    final Map<String, Boolean> areReopened = this.indices.areReopened(indices);
    for (IndexStatistics indexStatistics : indicesStatistics) {
        final IndexInfo indexInfo = IndexInfo.create(indexStatistics.primaryShards(), indexStatistics.allShards(), fillShardRoutings(indexStatistics.routing()), areReopened.get(indexStatistics.index()));
        indexInfos.put(indexStatistics.index(), indexInfo);
    }
    return OpenIndicesInfo.create(indexInfos);
}
Also used : IndexStatistics(org.graylog2.indexer.indices.stats.IndexStatistics) HashMap(java.util.HashMap) IndexInfo(org.graylog2.rest.models.system.indexer.responses.IndexInfo)

Example 7 with IndexStatistics

use of org.graylog2.indexer.indices.stats.IndexStatistics in project graylog2-server by Graylog2.

the class IndicesResource method indexSetOpen.

@GET
@Path("/{indexSetId}/open")
@Timed
@ApiOperation(value = "Get information of all open indices managed by Graylog and their shards.")
@RequiresPermissions(RestPermissions.INDICES_READ)
@Produces(MediaType.APPLICATION_JSON)
public OpenIndicesInfo indexSetOpen(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
    final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
    final Set<IndexStatistics> indicesInfos = indices.getIndicesStats(indexSet).stream().filter(indexStats -> isPermitted(RestPermissions.INDICES_READ, indexStats.index())).collect(Collectors.toSet());
    return getOpenIndicesInfo(indicesInfos);
}
Also used : IndexStatistics(org.graylog2.indexer.indices.stats.IndexStatistics) IndicesReadRequest(org.graylog2.rest.models.system.indexer.requests.IndicesReadRequest) PathParam(javax.ws.rs.PathParam) AllIndices(org.graylog2.rest.models.system.indexer.responses.AllIndices) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) HashMap(java.util.HashMap) ApiResponses(io.swagger.annotations.ApiResponses) ClosedIndices(org.graylog2.rest.models.system.indexer.responses.ClosedIndices) Inject(javax.inject.Inject) Valid(javax.validation.Valid) ApiOperation(io.swagger.annotations.ApiOperation) ShardRouting(org.graylog2.rest.models.system.indexer.responses.ShardRouting) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) MediaType(javax.ws.rs.core.MediaType) Indices(org.graylog2.indexer.indices.Indices) Map(java.util.Map) AuditEvent(org.graylog2.audit.jersey.AuditEvent) IndexStatistics(org.graylog2.indexer.indices.stats.IndexStatistics) Api(io.swagger.annotations.Api) IndexSet(org.graylog2.indexer.IndexSet) IndexSetRegistry(org.graylog2.indexer.IndexSetRegistry) DELETE(javax.ws.rs.DELETE) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) ForbiddenException(javax.ws.rs.ForbiddenException) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) IndexInfo(org.graylog2.rest.models.system.indexer.responses.IndexInfo) Set(java.util.Set) RestResource(org.graylog2.shared.rest.resources.RestResource) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) Timed(com.codahale.metrics.annotation.Timed) List(java.util.List) ApiResponse(io.swagger.annotations.ApiResponse) AuditEventTypes(org.graylog2.audit.AuditEventTypes) OpenIndicesInfo(org.graylog2.rest.models.system.indexer.responses.OpenIndicesInfo) RestPermissions(org.graylog2.shared.security.RestPermissions) NodeInfoCache(org.graylog2.indexer.NodeInfoCache) RequiresAuthentication(org.apache.shiro.authz.annotation.RequiresAuthentication) TooManyAliasesException(org.graylog2.indexer.indices.TooManyAliasesException) IndexSet(org.graylog2.indexer.IndexSet) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 8 with IndexStatistics

use of org.graylog2.indexer.indices.stats.IndexStatistics in project graylog2-server by Graylog2.

the class IndicesAdapterES6 method indicesStats.

@Override
public Set<IndexStatistics> indicesStats(Collection<String> indices) {
    final ImmutableSet.Builder<IndexStatistics> result = ImmutableSet.builder();
    final JsonNode allWithShardLevel = getAllWithShardLevel(indices);
    final Iterator<Map.Entry<String, JsonNode>> fields = allWithShardLevel.fields();
    while (fields.hasNext()) {
        final Map.Entry<String, JsonNode> entry = fields.next();
        final String index = entry.getKey();
        final JsonNode indexStats = entry.getValue();
        if (indexStats.isObject()) {
            result.add(buildIndexStatistics(index, indexStats));
        }
    }
    return result.build();
}
Also used : IndexStatistics(org.graylog2.indexer.indices.stats.IndexStatistics) ImmutableSet(com.google.common.collect.ImmutableSet) JsonNode(com.fasterxml.jackson.databind.JsonNode) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Aggregations

IndexStatistics (org.graylog2.indexer.indices.stats.IndexStatistics)6 ImmutableMap (com.google.common.collect.ImmutableMap)4 HashMap (java.util.HashMap)4 Map (java.util.Map)3 IndexInfo (org.graylog2.rest.models.system.indexer.responses.IndexInfo)3 Test (org.junit.Test)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 CommonStats (org.elasticsearch.action.admin.indices.stats.CommonStats)2 StoreStats (org.elasticsearch.index.store.StoreStats)2 IndexStatistics (org.graylog2.indexer.indices.IndexStatistics)2 Timed (com.codahale.metrics.annotation.Timed)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 ApiResponse (io.swagger.annotations.ApiResponse)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Collection (java.util.Collection)1 List (java.util.List)1 Set (java.util.Set)1