health.asciidoc 6.2 KB

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