health.asciidoc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. [[cluster-health]]
  2. == Cluster Health
  3. The cluster health API allows to get a very simple status on the health
  4. of the cluster. For example, on a quiet single node cluster with a single index
  5. with 5 shards and one replica, this:
  6. [source,js]
  7. --------------------------------------------------
  8. GET _cluster/health
  9. --------------------------------------------------
  10. // CONSOLE
  11. // TEST[s/^/PUT test1\n/]
  12. Returns this:
  13. --------------------------------------------------
  14. {
  15. "cluster_name" : "testcluster",
  16. "status" : "yellow",
  17. "timed_out" : false,
  18. "number_of_nodes" : 1,
  19. "number_of_data_nodes" : 1,
  20. "active_primary_shards" : 5,
  21. "active_shards" : 5,
  22. "relocating_shards" : 0,
  23. "initializing_shards" : 0,
  24. "unassigned_shards" : 5,
  25. "delayed_unassigned_shards": 0,
  26. "number_of_pending_tasks" : 0,
  27. "number_of_in_flight_fetch": 0,
  28. "task_max_waiting_in_queue_millis": 0,
  29. "active_shards_percent_as_number": 50.0
  30. }
  31. --------------------------------------------------
  32. // TESTRESPONSE[s/testcluster/docs_integTest/]
  33. // TESTRESPONSE[s/"number_of_pending_tasks" : 0,/"number_of_pending_tasks" : $body.number_of_pending_tasks,/]
  34. // TESTRESPONSE[s/"task_max_waiting_in_queue_millis": 0/"task_max_waiting_in_queue_millis": $body.task_max_waiting_in_queue_millis/]
  35. The API can also be executed against one or more indices to get just the
  36. specified indices health:
  37. [source,js]
  38. --------------------------------------------------
  39. GET /_cluster/health/test1,test2
  40. --------------------------------------------------
  41. // CONSOLE
  42. // TEST[s/^/PUT test1\nPUT test2\n/]
  43. The cluster health status is: `green`, `yellow` or `red`. On the shard
  44. level, a `red` status indicates that the specific shard is not allocated
  45. in the cluster, `yellow` means that the primary shard is allocated but
  46. replicas are not, and `green` means that all shards are allocated. The
  47. index level status is controlled by the worst shard status. The cluster
  48. status is controlled by the worst index status.
  49. One of the main benefits of the API is the ability to wait until the
  50. cluster reaches a certain high water-mark health level. For example, the
  51. following will wait for 50 seconds for the cluster to reach the `yellow`
  52. level (if it reaches the `green` or `yellow` status before 50 seconds elapse,
  53. it will return at that point):
  54. [source,js]
  55. --------------------------------------------------
  56. GET /_cluster/health?wait_for_status=yellow&timeout=50s
  57. --------------------------------------------------
  58. // CONSOLE
  59. [float]
  60. [[request-params]]
  61. === Request Parameters
  62. The cluster health API accepts the following request parameters:
  63. `level`::
  64. Can be one of `cluster`, `indices` or `shards`. Controls the
  65. details level of the health information returned. Defaults to `cluster`.
  66. `wait_for_status`::
  67. One of `green`, `yellow` or `red`. Will wait (until
  68. the timeout provided) until the status of the cluster changes to the one
  69. provided or better, i.e. `green` > `yellow` > `red`. By default, will not
  70. wait for any status.
  71. `wait_for_relocating_shards`::
  72. A number controlling to how many relocating
  73. shards to wait for. Usually will be `0` to indicate to wait till all
  74. relocations have happened. Defaults to not wait.
  75. `wait_for_active_shards`::
  76. A number controlling to how many active
  77. shards to wait for. Defaults to not wait.
  78. `wait_for_nodes`::
  79. The request waits until the specified number `N` of
  80. nodes is available. It also accepts `>=N`, `<=N`, `>N` and `<N`.
  81. Alternatively, it is possible to use `ge(N)`, `le(N)`, `gt(N)` and
  82. `lt(N)` notation.
  83. `timeout`::
  84. A time based parameter controlling how long to wait if one of
  85. the wait_for_XXX are provided. Defaults to `30s`.
  86. `local`::
  87. If `true` returns the local node information and does not provide
  88. the state from master node. Default: `false`.
  89. The following is an example of getting the cluster health at the
  90. `shards` level:
  91. [source,js]
  92. --------------------------------------------------
  93. GET /_cluster/health/twitter?level=shards
  94. --------------------------------------------------
  95. // CONSOLE
  96. // TEST[setup:twitter]