stats.asciidoc 7.5 KB

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