health.asciidoc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. [[cluster-health]]
  2. === Cluster health API
  3. ++++
  4. <titleabbrev>Cluster health</titleabbrev>
  5. ++++
  6. Returns the health status of a cluster.
  7. [[cluster-health-api-request]]
  8. ==== {api-request-title}
  9. `GET _cluster/health/<index>`
  10. [[cluster-health-api-desc]]
  11. ==== {api-description-title}
  12. The cluster health API returns a simple status on the health of the
  13. cluster. The API can also be executed against one or more indices to get just
  14. the specified indices health.
  15. The cluster health status is: `green`, `yellow` or `red`. On the shard level, a
  16. `red` status indicates that the specific shard is not allocated in the cluster,
  17. `yellow` means that the primary shard is allocated but replicas are not, and
  18. `green` means that all shards are allocated. The index level status is
  19. controlled by the worst shard status. The cluster status is controlled by the
  20. worst index status.
  21. One of the main benefits of the API is the ability to wait until the cluster
  22. reaches a certain high water-mark health level. For example, the following will
  23. wait for 50 seconds for the cluster to reach the `yellow` level (if it reaches
  24. the `green` or `yellow` status before 50 seconds elapse, it will return at that
  25. point):
  26. [source,console]
  27. --------------------------------------------------
  28. GET /_cluster/health?wait_for_status=yellow&timeout=50s
  29. --------------------------------------------------
  30. [[cluster-health-api-path-params]]
  31. ==== {api-path-parms-title}
  32. include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
  33. [[cluster-health-api-query-params]]
  34. ==== {api-query-parms-title}
  35. `level`::
  36. (Optional, string) Can be one of `cluster`, `indices` or `shards`. Controls
  37. the details level of the health information returned. Defaults to `cluster`.
  38. include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
  39. include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  40. `wait_for_active_shards`::
  41. (Optional, string) A number controlling to how many active shards to wait
  42. for, `all` to wait for all shards in the cluster to be active, or `0` to not
  43. wait. Defaults to `0`.
  44. `wait_for_events`::
  45. (Optional, string) Can be one of `immediate`, `urgent`, `high`, `normal`,
  46. `low`, `languid`. Wait until all currently queued events with the given
  47. priority are processed.
  48. `wait_for_no_initializing_shards`::
  49. (Optional, boolean) A boolean value which controls whether to wait (until
  50. the timeout provided) for the cluster to have no shard initializations.
  51. Defaults to false, which means it will not wait for initializing shards.
  52. `wait_for_no_relocating_shards`::
  53. (Optional, boolean) A boolean value which controls whether to wait (until
  54. the timeout provided) for the cluster to have no shard relocations. Defaults
  55. to false, which means it will not wait for relocating shards.
  56. `wait_for_nodes`::
  57. (Optional, string) The request waits until the specified number `N` of
  58. nodes is available. It also accepts `>=N`, `<=N`, `>N` and `<N`.
  59. Alternatively, it is possible to use `ge(N)`, `le(N)`, `gt(N)` and
  60. `lt(N)` notation.
  61. `wait_for_status`::
  62. (Optional, string) One of `green`, `yellow` or `red`. Will wait (until the
  63. timeout provided) until the status of the cluster changes to the one
  64. provided or better, i.e. `green` > `yellow` > `red`. By default, will not
  65. wait for any status.
  66. [[cluster-health-api-response-body]]
  67. ==== {api-response-body-title}
  68. `cluster_name`::
  69. (string) The name of the cluster.
  70. `status`::
  71. (string) The health status of the cluster.
  72. `timed_out`::
  73. (boolean) If `false` the response returned within the period of
  74. time that is specified by the `timeout` parameter (`30s` by default).
  75. `number_of_nodes`::
  76. (integer) The number of nodes within the cluster.
  77. `number_of_data_nodes`::
  78. (integer) The number of nodes that are dedicated data nodes.
  79. `active_primary_shards`::
  80. (integer) The number of active primary shards.
  81. `active_shards`::
  82. (integer) The total number of active primary and replica shards.
  83. `relocating_shards`::
  84. (integer) The number of shards that are under relocation.
  85. `initializing_shards`::
  86. (integer) The number of shards that are under initialization.
  87. `unassigned_shards`::
  88. (integer) The number of shards that are not allocated.
  89. `delayed_unassigned_shards`::
  90. (integer) The number of shards whose allocation has been delayed by the
  91. timeout settings.
  92. `number_of_pending_tasks`::
  93. (integer) The number of cluster-level changes that have not yet been
  94. executed.
  95. `number_of_in_flight_fetch`::
  96. (integer) The number of unfinished fetches.
  97. `task_max_waiting_in_queue_millis`::
  98. (integer) The time expressed in milliseconds since the earliest initiated task
  99. is waiting for being performed.
  100. `active_shards_percent_as_number`::
  101. (float) The ratio of active shards in the cluster expressed as a percentage.
  102. [[cluster-health-api-example]]
  103. ==== {api-examples-title}
  104. [source,console]
  105. --------------------------------------------------
  106. GET _cluster/health
  107. --------------------------------------------------
  108. // TEST[s/^/PUT test1\n/]
  109. The API returns the following response in case of a quiet single node cluster
  110. with a single index with one shard and one replica:
  111. [source,console-result]
  112. --------------------------------------------------
  113. {
  114. "cluster_name" : "testcluster",
  115. "status" : "yellow",
  116. "timed_out" : false,
  117. "number_of_nodes" : 1,
  118. "number_of_data_nodes" : 1,
  119. "active_primary_shards" : 1,
  120. "active_shards" : 1,
  121. "relocating_shards" : 0,
  122. "initializing_shards" : 0,
  123. "unassigned_shards" : 1,
  124. "delayed_unassigned_shards": 0,
  125. "number_of_pending_tasks" : 0,
  126. "number_of_in_flight_fetch": 0,
  127. "task_max_waiting_in_queue_millis": 0,
  128. "active_shards_percent_as_number": 50.0
  129. }
  130. --------------------------------------------------
  131. // TESTRESPONSE[s/testcluster/integTest/]
  132. // TESTRESPONSE[s/"number_of_pending_tasks" : 0,/"number_of_pending_tasks" : $body.number_of_pending_tasks,/]
  133. // TESTRESPONSE[s/"task_max_waiting_in_queue_millis": 0/"task_max_waiting_in_queue_millis": $body.task_max_waiting_in_queue_millis/]
  134. The following is an example of getting the cluster health at the
  135. `shards` level:
  136. [source,console]
  137. --------------------------------------------------
  138. GET /_cluster/health/twitter?level=shards
  139. --------------------------------------------------
  140. // TEST[setup:twitter]