health.asciidoc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 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. The API can also be executed against one or more indices to get just the
  34. specified indices health:
  35. [source,js]
  36. --------------------------------------------------
  37. GET /_cluster/health/test1,test2
  38. --------------------------------------------------
  39. // CONSOLE
  40. // TEST[s/^/PUT test1\nPUT test2\n/]
  41. The cluster health status is: `green`, `yellow` or `red`. On the shard
  42. level, a `red` status indicates that the specific shard is not allocated
  43. in the cluster, `yellow` means that the primary shard is allocated but
  44. replicas are not, and `green` means that all shards are allocated. The
  45. index level status is controlled by the worst shard status. The cluster
  46. status is controlled by the worst index status.
  47. One of the main benefits of the API is the ability to wait until the
  48. cluster reaches a certain high water-mark health level. For example, the
  49. following will wait for 50 seconds for the cluster to reach the `yellow`
  50. level (if it reaches the `green` or `yellow` status before 50 seconds elapse,
  51. it will return at that point):
  52. [source,js]
  53. --------------------------------------------------
  54. GET /_cluster/health?wait_for_status=yellow&timeout=50s
  55. --------------------------------------------------
  56. // CONSOLE
  57. [float]
  58. [[request-params]]
  59. === Request Parameters
  60. The cluster health API accepts the following request parameters:
  61. `level`::
  62. Can be one of `cluster`, `indices` or `shards`. Controls the
  63. details level of the health information returned. Defaults to `cluster`.
  64. `wait_for_status`::
  65. One of `green`, `yellow` or `red`. Will wait (until
  66. the timeout provided) until the status of the cluster changes to the one
  67. provided or better, i.e. `green` > `yellow` > `red`. By default, will not
  68. wait for any status.
  69. `wait_for_relocating_shards`::
  70. A number controlling to how many relocating
  71. shards to wait for. Usually will be `0` to indicate to wait till all
  72. relocations have happened. Defaults to not wait.
  73. `wait_for_active_shards`::
  74. A number controlling to how many active
  75. shards to wait for. Defaults to not wait.
  76. `wait_for_nodes`::
  77. The request waits until the specified number `N` of
  78. nodes is available. It also accepts `>=N`, `<=N`, `>N` and `<N`.
  79. Alternatively, it is possible to use `ge(N)`, `le(N)`, `gt(N)` and
  80. `lt(N)` notation.
  81. `timeout`::
  82. A time based parameter controlling how long to wait if one of
  83. the wait_for_XXX are provided. Defaults to `30s`.
  84. `local`::
  85. If `true` returns the local node information and does not provide
  86. the state from master node. Default: `false`.
  87. The following is an example of getting the cluster health at the
  88. `shards` level:
  89. [source,js]
  90. --------------------------------------------------
  91. GET /_cluster/health/twitter?level=shards
  92. --------------------------------------------------
  93. // CONSOLE
  94. // TEST[setup:twitter]