stats.asciidoc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. [[cluster-stats]]
  2. === Cluster Stats
  3. Returns cluster statistics.
  4. [[cluster-stats-api-request]]
  5. ==== {api-request-title}
  6. `GET /_cluster/stats` +
  7. `GET /_cluster/stats/nodes/<node_id>`
  8. [[cluster-stats-api-desc]]
  9. ==== {api-description-title}
  10. The Cluster Stats API allows to retrieve statistics from a cluster wide
  11. perspective. The API returns basic index metrics (shard numbers, store size,
  12. memory usage) and information about the current nodes that form the cluster
  13. (number, roles, os, jvm versions, memory usage, cpu and installed plugins).
  14. [[cluster-stats-api-path-params]]
  15. ==== {api-path-parms-title}
  16. include::{docdir}/rest-api/common-parms.asciidoc[tag=node-id]
  17. [[cluster-stats-api-query-params]]
  18. ==== {api-query-parms-title}
  19. include::{docdir}/rest-api/common-parms.asciidoc[tag=flat-settings]
  20. include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  21. [[cluster-stats-api-example]]
  22. ==== {api-examples-title}
  23. [source,console]
  24. --------------------------------------------------
  25. GET /_cluster/stats?human&pretty
  26. --------------------------------------------------
  27. // TEST[setup:twitter]
  28. The API returns the following response:
  29. ["source","js",subs="attributes,callouts"]
  30. --------------------------------------------------
  31. {
  32. "_nodes" : {
  33. "total" : 1,
  34. "successful" : 1,
  35. "failed" : 0
  36. },
  37. "cluster_uuid": "YjAvIhsCQ9CbjWZb2qJw3Q",
  38. "cluster_name": "elasticsearch",
  39. "timestamp": 1459427693515,
  40. "status": "green",
  41. "indices": {
  42. "count": 1,
  43. "shards": {
  44. "total": 5,
  45. "primaries": 5,
  46. "replication": 0,
  47. "index": {
  48. "shards": {
  49. "min": 5,
  50. "max": 5,
  51. "avg": 5
  52. },
  53. "primaries": {
  54. "min": 5,
  55. "max": 5,
  56. "avg": 5
  57. },
  58. "replication": {
  59. "min": 0,
  60. "max": 0,
  61. "avg": 0
  62. }
  63. }
  64. },
  65. "docs": {
  66. "count": 10,
  67. "deleted": 0
  68. },
  69. "store": {
  70. "size": "16.2kb",
  71. "size_in_bytes": 16684
  72. },
  73. "fielddata": {
  74. "memory_size": "0b",
  75. "memory_size_in_bytes": 0,
  76. "evictions": 0
  77. },
  78. "query_cache": {
  79. "memory_size": "0b",
  80. "memory_size_in_bytes": 0,
  81. "total_count": 0,
  82. "hit_count": 0,
  83. "miss_count": 0,
  84. "cache_size": 0,
  85. "cache_count": 0,
  86. "evictions": 0
  87. },
  88. "completion": {
  89. "size": "0b",
  90. "size_in_bytes": 0
  91. },
  92. "segments": {
  93. "count": 4,
  94. "memory": "8.6kb",
  95. "memory_in_bytes": 8898,
  96. "terms_memory": "6.3kb",
  97. "terms_memory_in_bytes": 6522,
  98. "stored_fields_memory": "1.2kb",
  99. "stored_fields_memory_in_bytes": 1248,
  100. "term_vectors_memory": "0b",
  101. "term_vectors_memory_in_bytes": 0,
  102. "norms_memory": "384b",
  103. "norms_memory_in_bytes": 384,
  104. "points_memory" : "0b",
  105. "points_memory_in_bytes" : 0,
  106. "doc_values_memory": "744b",
  107. "doc_values_memory_in_bytes": 744,
  108. "index_writer_memory": "0b",
  109. "index_writer_memory_in_bytes": 0,
  110. "version_map_memory": "0b",
  111. "version_map_memory_in_bytes": 0,
  112. "fixed_bit_set": "0b",
  113. "fixed_bit_set_memory_in_bytes": 0,
  114. "max_unsafe_auto_id_timestamp" : -9223372036854775808,
  115. "file_sizes": {}
  116. }
  117. },
  118. "nodes": {
  119. "count": {
  120. "total": 1,
  121. "data": 1,
  122. "coordinating_only": 0,
  123. "master": 1,
  124. "ingest": 1,
  125. "voting_only": 0
  126. },
  127. "versions": [
  128. "{version}"
  129. ],
  130. "os": {
  131. "available_processors": 8,
  132. "allocated_processors": 8,
  133. "names": [
  134. {
  135. "name": "Mac OS X",
  136. "count": 1
  137. }
  138. ],
  139. "pretty_names": [
  140. {
  141. "pretty_name": "Mac OS X",
  142. "count": 1
  143. }
  144. ],
  145. "mem" : {
  146. "total" : "16gb",
  147. "total_in_bytes" : 17179869184,
  148. "free" : "78.1mb",
  149. "free_in_bytes" : 81960960,
  150. "used" : "15.9gb",
  151. "used_in_bytes" : 17097908224,
  152. "free_percent" : 0,
  153. "used_percent" : 100
  154. }
  155. },
  156. "process": {
  157. "cpu": {
  158. "percent": 9
  159. },
  160. "open_file_descriptors": {
  161. "min": 268,
  162. "max": 268,
  163. "avg": 268
  164. }
  165. },
  166. "jvm": {
  167. "max_uptime": "13.7s",
  168. "max_uptime_in_millis": 13737,
  169. "versions": [
  170. {
  171. "version": "12",
  172. "vm_name": "OpenJDK 64-Bit Server VM",
  173. "vm_version": "12+33",
  174. "vm_vendor": "Oracle Corporation",
  175. "bundled_jdk": true,
  176. "using_bundled_jdk": true,
  177. "count": 1
  178. }
  179. ],
  180. "mem": {
  181. "heap_used": "57.5mb",
  182. "heap_used_in_bytes": 60312664,
  183. "heap_max": "989.8mb",
  184. "heap_max_in_bytes": 1037959168
  185. },
  186. "threads": 90
  187. },
  188. "fs": {
  189. "total": "200.6gb",
  190. "total_in_bytes": 215429193728,
  191. "free": "32.6gb",
  192. "free_in_bytes": 35064553472,
  193. "available": "32.4gb",
  194. "available_in_bytes": 34802409472
  195. },
  196. "plugins": [
  197. {
  198. "name": "analysis-icu",
  199. "version": "{version}",
  200. "description": "The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components.",
  201. "classname": "org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin",
  202. "has_native_controller": false
  203. },
  204. ...
  205. ],
  206. "network_types": {
  207. ...
  208. },
  209. "discovery_types": {
  210. ...
  211. },
  212. "packaging_types": [
  213. {
  214. ...
  215. }
  216. ]
  217. }
  218. }
  219. --------------------------------------------------
  220. // TESTRESPONSE[s/"plugins": \[[^\]]*\]/"plugins": $body.$_path/]
  221. // TESTRESPONSE[s/"network_types": \{[^\}]*\}/"network_types": $body.$_path/]
  222. // TESTRESPONSE[s/"discovery_types": \{[^\}]*\}/"discovery_types": $body.$_path/]
  223. // TESTRESPONSE[s/"count": \{[^\}]*\}/"count": $body.$_path/]
  224. // TESTRESPONSE[s/"packaging_types": \[[^\]]*\]/"packaging_types": $body.$_path/]
  225. // TESTRESPONSE[s/: true|false/: $body.$_path/]
  226. // TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
  227. // TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
  228. // These replacements do a few things:
  229. // 1. Ignore the contents of the `plugins` object because we don't know all of
  230. // the plugins that will be in it. And because we figure folks don't need to
  231. // see an exhaustive list anyway.
  232. // 2. Similarly, ignore the contents of `network_types`, `discovery_types`, and
  233. // `packaging_types`.
  234. // 3. Ignore the contents of the (nodes) count object, as what's shown here
  235. // depends on the license. Voting-only nodes are e.g. only shown when this
  236. // test runs with a basic license.
  237. // 4. All of the numbers and strings on the right hand side of *every* field in
  238. // the response are ignored. So we're really only asserting things about the
  239. // the shape of this response, not the values in it.
  240. This API can be restricted to a subset of the nodes using <<cluster-nodes,node
  241. filters>>:
  242. [source,console]
  243. --------------------------------------------------
  244. GET /_cluster/stats/nodes/node1,node*,master:false
  245. --------------------------------------------------