Skip to content

Commit

Permalink
Added Cluster Stats API
Browse files Browse the repository at this point in the history
  • Loading branch information
bleskes committed Dec 17, 2013
1 parent 2047044 commit bd9fac5
Show file tree
Hide file tree
Showing 22 changed files with 2,121 additions and 16 deletions.
2 changes: 2 additions & 0 deletions docs/reference/cluster.asciidoc
Expand Up @@ -33,6 +33,8 @@ include::cluster/health.asciidoc[]

include::cluster/state.asciidoc[]

include::cluster/stats.asciidoc[]

include::cluster/pending.asciidoc[]

include::cluster/reroute.asciidoc[]
Expand Down
165 changes: 165 additions & 0 deletions docs/reference/cluster/stats.asciidoc
@@ -0,0 +1,165 @@
[[cluster-stats]]
== Cluster Stats

added[0.90.8]

The Cluster Stats API allows to retrieve statistics from a cluster wide perspective.
The API returns basic index metrics (shard numbers, store size, memory usage) and
information about the current nodes that form the cluster (number, roles, os, jvm
versions, memory usage, cpu and installed plugins).

[source,js]
--------------------------------------------------
curl -XGET 'http://localhost:9200/_cluster/stats?human'
--------------------------------------------------

Will return, for example:
[source,js]
--------------------------------------------------
{
"cluster_name": "elasticsearch",
"indices": {
"count": 3,
"shards": {
"total": 35,
"primaries": 15,
"replication": 1.333333333333333,
"index": {
"shards": {
"min": 10,
"max": 15,
"avg": 11.66666666666666
},
"primaries": {
"min": 5,
"max": 5,
"avg": 5
},
"replication": {
"min": 1,
"max": 2,
"avg": 1.3333333333333333
}
}
},
"docs": {
"count": 2,
"deleted": 0
},
"store": {
"size": "5.6kb",
"size_in_bytes": 5770,
"throttle_time": "0s",
"throttle_time_in_millis": 0
},
"fielddata": {
"memory_size": "0b",
"memory_size_in_bytes": 0,
"evictions": 0
},
"filter_cache": {
"memory_size": "0b",
"memory_size_in_bytes": 0,
"evictions": 0
},
"id_cache": {
"memory_size": "0b",
"memory_size_in_bytes": 0
},
"completion": {
"size": "0b",
"size_in_bytes": 0
},
"segments": {
"count": 2
}
},
"nodes": {
"count": {
"total": 2,
"master_only": 0,
"data_only": 0,
"master_data": 2,
"client": 0
},
"versions": [
"0.90.8"
],
"os": {
"available_processors": 4,
"mem": {
"total": "8gb",
"total_in_bytes": 8589934592
},
"cpu": [
{
"vendor": "Intel",
"model": "MacBookAir5,2",
"mhz": 2000,
"total_cores": 4,
"total_sockets": 4,
"cores_per_socket": 16,
"cache_size": "256b",
"cache_size_in_bytes": 256,
"count": 1
}
]
},
"process": {
"cpu": {
"percent": 3
},
"avg_open_file_descriptors": 218
},
"jvm": {
"max_uptime": "24s",
"max_uptime_in_millis": 24054,
"version": [
{
"version": "1.6.0_45",
"vm_name": "Java HotSpot(TM) 64-Bit Server VM",
"vm_version": "20.45-b01-451",
"vm_vendor": "Apple Inc.",
"count": 2
}
],
"mem": {
"heap_used": "38.3mb",
"heap_used_in_bytes": 40237120,
"heap_max": "1.9gb",
"heap_max_in_bytes": 2130051072
},
"threads": 89
},
"fs":
{
"total": "232.9gb",
"total_in_bytes": 250140434432,
"free": "31.3gb",
"free_in_bytes": 33705881600,
"available": "31.1gb",
"available_in_bytes": 33443737600,
"disk_reads": 21202753,
"disk_writes": 27028840,
"disk_io_op": 48231593,
"disk_read_size": "528gb",
"disk_read_size_in_bytes": 566980806656,
"disk_write_size": "617.9gb",
"disk_write_size_in_bytes": 663525366784,
"disk_io_size": "1145.9gb",
"disk_io_size_in_bytes": 1230506173440
},
"plugins": [
// all plugins installed on nodes
{
"name": "inquisitor",
"description": "",
"url": "/_plugin/inquisitor/",
"jvm": false,
"site": true
}
]
}
}
--------------------------------------------------

3 changes: 3 additions & 0 deletions src/main/java/org/elasticsearch/action/ActionModule.java
Expand Up @@ -40,6 +40,8 @@
import org.elasticsearch.action.admin.cluster.shards.TransportClusterSearchShardsAction;
import org.elasticsearch.action.admin.cluster.state.ClusterStateAction;
import org.elasticsearch.action.admin.cluster.state.TransportClusterStateAction;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsAction;
import org.elasticsearch.action.admin.cluster.stats.TransportClusterStatsAction;
import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksAction;
import org.elasticsearch.action.admin.cluster.tasks.TransportPendingClusterTasksAction;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction;
Expand Down Expand Up @@ -181,6 +183,7 @@ protected void configure() {
registerAction(NodesRestartAction.INSTANCE, TransportNodesRestartAction.class);
registerAction(NodesHotThreadsAction.INSTANCE, TransportNodesHotThreadsAction.class);

registerAction(ClusterStatsAction.INSTANCE, TransportClusterStatsAction.class);
registerAction(ClusterStateAction.INSTANCE, TransportClusterStateAction.class);
registerAction(ClusterHealthAction.INSTANCE, TransportClusterHealthAction.class);
registerAction(ClusterUpdateSettingsAction.INSTANCE, TransportClusterUpdateSettingsAction.class);
Expand Down
Expand Up @@ -29,10 +29,11 @@ public PluginInfo() {

/**
* Information about plugins
* @param name Its name
*
* @param name Its name
* @param description Its description
* @param site true if it's a site plugin
* @param jvm true if it's a jvm plugin
* @param site true if it's a site plugin
* @param jvm true if it's a jvm plugin
*/
public PluginInfo(String name, String description, boolean site, boolean jvm) {
this.name = name;
Expand Down Expand Up @@ -71,6 +72,7 @@ public boolean isJvm() {

/**
* We compute the URL for sites: "/_plugin/" + name + "/"
*
* @return
*/
public String getUrl() {
Expand Down Expand Up @@ -117,4 +119,24 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws

return builder;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

PluginInfo p = (PluginInfo) o;

return name.equals(p.getName());
}

@Override
public int hashCode() {
return name.hashCode();
}

}
@@ -0,0 +1,45 @@
/*
* Licensed to ElasticSearch and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. ElasticSearch licenses this
* file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.action.admin.cluster.stats;

import org.elasticsearch.action.admin.cluster.ClusterAction;
import org.elasticsearch.client.ClusterAdminClient;

/**
*/
public class ClusterStatsAction extends ClusterAction<ClusterStatsRequest, ClusterStatsResponse, ClusterStatsRequestBuilder> {

public static final ClusterStatsAction INSTANCE = new ClusterStatsAction();
public static final String NAME = "cluster/stats";

private ClusterStatsAction() {
super(NAME);
}

@Override
public ClusterStatsResponse newResponse() {
return new ClusterStatsResponse();
}

@Override
public ClusterStatsRequestBuilder newRequestBuilder(ClusterAdminClient client) {
return new ClusterStatsRequestBuilder(client);
}
}

0 comments on commit bd9fac5

Please sign in to comment.