Search in sources :

Example 1 with ClusterIndexHealth

use of org.elasticsearch.cluster.health.ClusterIndexHealth in project elasticsearch by elastic.

the class RestIndicesAction method buildTable.

// package private for testing
Table buildTable(RestRequest request, Index[] indices, ClusterHealthResponse response, IndicesStatsResponse stats, MetaData indexMetaDatas) {
    final String healthParam = request.param("health");
    final ClusterHealthStatus status;
    if (healthParam != null) {
        status = ClusterHealthStatus.fromString(healthParam);
    } else {
        status = null;
    }
    Table table = getTableWithHeader(request);
    for (final Index index : indices) {
        final String indexName = index.getName();
        ClusterIndexHealth indexHealth = response.getIndices().get(indexName);
        IndexStats indexStats = stats.getIndices().get(indexName);
        IndexMetaData indexMetaData = indexMetaDatas.getIndices().get(indexName);
        IndexMetaData.State state = indexMetaData.getState();
        if (status != null) {
            if (state == IndexMetaData.State.CLOSE || (indexHealth == null && !ClusterHealthStatus.RED.equals(status)) || !indexHealth.getStatus().equals(status)) {
                continue;
            }
        }
        table.startRow();
        table.addCell(state == IndexMetaData.State.OPEN ? (indexHealth == null ? "red*" : indexHealth.getStatus().toString().toLowerCase(Locale.ROOT)) : null);
        table.addCell(state.toString().toLowerCase(Locale.ROOT));
        table.addCell(indexName);
        table.addCell(index.getUUID());
        table.addCell(indexHealth == null ? null : indexHealth.getNumberOfShards());
        table.addCell(indexHealth == null ? null : indexHealth.getNumberOfReplicas());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getDocs().getCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getDocs().getDeleted());
        table.addCell(indexMetaData.getCreationDate());
        table.addCell(new DateTime(indexMetaData.getCreationDate(), DateTimeZone.UTC));
        table.addCell(indexStats == null ? null : indexStats.getTotal().getStore().size());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getStore().size());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getCompletion().getSize());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getCompletion().getSize());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getFieldData().getMemorySize());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getFieldData().getMemorySize());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getFieldData().getEvictions());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getFieldData().getEvictions());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getQueryCache().getMemorySize());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getQueryCache().getMemorySize());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getQueryCache().getEvictions());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getQueryCache().getEvictions());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getRequestCache().getMemorySize());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRequestCache().getMemorySize());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getRequestCache().getEvictions());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRequestCache().getEvictions());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getRequestCache().getHitCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRequestCache().getHitCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getRequestCache().getMissCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRequestCache().getMissCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getFlush().getTotal());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getFlush().getTotal());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getFlush().getTotalTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getFlush().getTotalTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().current());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().current());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getExistsTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getExistsTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getExistsCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getExistsCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getMissingTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getMissingTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getGet().getMissingCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getGet().getMissingCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getDeleteCurrent());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getDeleteCurrent());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getDeleteTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getDeleteTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getDeleteCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getDeleteCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getIndexCurrent());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getIndexCurrent());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getIndexTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getIndexTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getIndexCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getIndexCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getIndexing().getTotal().getIndexFailedCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getIndexing().getTotal().getIndexFailedCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getCurrent());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getCurrent());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getCurrentNumDocs());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getCurrentNumDocs());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getCurrentSize());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getCurrentSize());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getTotal());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getTotal());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getTotalNumDocs());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getTotalNumDocs());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getTotalSize());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getTotalSize());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getMerge().getTotalTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getMerge().getTotalTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getRefresh().getTotal());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRefresh().getTotal());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getRefresh().getTotalTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRefresh().getTotalTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getRefresh().getListeners());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getRefresh().getListeners());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getFetchCurrent());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getFetchCurrent());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getFetchTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getFetchTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getFetchCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getFetchCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getOpenContexts());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getOpenContexts());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getQueryCurrent());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getQueryCurrent());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getQueryTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getQueryTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getQueryCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getQueryCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getScrollCurrent());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getScrollCurrent());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getScrollTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getScrollTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getScrollCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getScrollCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getMemory());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getMemory());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getIndexWriterMemory());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getIndexWriterMemory());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getVersionMapMemory());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getVersionMapMemory());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSegments().getBitsetMemory());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSegments().getBitsetMemory());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getWarmer().current());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getWarmer().current());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getWarmer().total());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getWarmer().total());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getWarmer().totalTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getWarmer().totalTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getSuggestCurrent());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getSuggestCurrent());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getSuggestTime());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getSuggestTime());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getSearch().getTotal().getSuggestCount());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getSearch().getTotal().getSuggestCount());
        table.addCell(indexStats == null ? null : indexStats.getTotal().getTotalMemory());
        table.addCell(indexStats == null ? null : indexStats.getPrimaries().getTotalMemory());
        table.endRow();
    }
    return table;
}
Also used : ClusterHealthStatus(org.elasticsearch.cluster.health.ClusterHealthStatus) Table(org.elasticsearch.common.Table) ClusterIndexHealth(org.elasticsearch.cluster.health.ClusterIndexHealth) Index(org.elasticsearch.index.Index) IndexStats(org.elasticsearch.action.admin.indices.stats.IndexStats) DateTime(org.joda.time.DateTime) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData)

Example 2 with ClusterIndexHealth

use of org.elasticsearch.cluster.health.ClusterIndexHealth in project elasticsearch by elastic.

the class ClusterHealthResponse method toXContent.

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.field(CLUSTER_NAME, getClusterName());
    builder.field(STATUS, getStatus().name().toLowerCase(Locale.ROOT));
    builder.field(TIMED_OUT, isTimedOut());
    builder.field(NUMBER_OF_NODES, getNumberOfNodes());
    builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes());
    builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards());
    builder.field(ACTIVE_SHARDS, getActiveShards());
    builder.field(RELOCATING_SHARDS, getRelocatingShards());
    builder.field(INITIALIZING_SHARDS, getInitializingShards());
    builder.field(UNASSIGNED_SHARDS, getUnassignedShards());
    builder.field(DELAYED_UNASSIGNED_SHARDS, getDelayedUnassignedShards());
    builder.field(NUMBER_OF_PENDING_TASKS, getNumberOfPendingTasks());
    builder.field(NUMBER_OF_IN_FLIGHT_FETCH, getNumberOfInFlightFetch());
    builder.timeValueField(TASK_MAX_WAIT_TIME_IN_QUEUE_IN_MILLIS, TASK_MAX_WAIT_TIME_IN_QUEUE, getTaskMaxWaitingTime());
    builder.percentageField(ACTIVE_SHARDS_PERCENT_AS_NUMBER, ACTIVE_SHARDS_PERCENT, getActiveShardsPercent());
    String level = params.param("level", "cluster");
    boolean outputIndices = "indices".equals(level) || "shards".equals(level);
    if (outputIndices) {
        builder.startObject(INDICES);
        for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) {
            builder.startObject(indexHealth.getIndex());
            indexHealth.toXContent(builder, params);
            builder.endObject();
        }
        builder.endObject();
    }
    builder.endObject();
    return builder;
}
Also used : ClusterIndexHealth(org.elasticsearch.cluster.health.ClusterIndexHealth)

Aggregations

ClusterIndexHealth (org.elasticsearch.cluster.health.ClusterIndexHealth)2 IndexStats (org.elasticsearch.action.admin.indices.stats.IndexStats)1 ClusterHealthStatus (org.elasticsearch.cluster.health.ClusterHealthStatus)1 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)1 Table (org.elasticsearch.common.Table)1 Index (org.elasticsearch.index.Index)1 DateTime (org.joda.time.DateTime)1