health.asciidoc 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.
  5. [source,js]
  6. --------------------------------------------------
  7. $ curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
  8. {
  9. "cluster_name" : "testcluster",
  10. "status" : "green",
  11. "timed_out" : false,
  12. "number_of_nodes" : 2,
  13. "number_of_data_nodes" : 2,
  14. "active_primary_shards" : 5,
  15. "active_shards" : 10,
  16. "relocating_shards" : 0,
  17. "initializing_shards" : 0,
  18. "unassigned_shards" : 0,
  19. "delayed_unassigned_shards": 0,
  20. "number_of_pending_tasks" : 0,
  21. "number_of_in_flight_fetch": 0,
  22. "task_max_waiting_in_queue_millis": 0,
  23. "active_shards_percent_as_number": 100
  24. }
  25. --------------------------------------------------
  26. The API can also be executed against one or more indices to get just the
  27. specified indices health:
  28. [source,js]
  29. --------------------------------------------------
  30. $ curl -XGET 'http://localhost:9200/_cluster/health/test1,test2'
  31. --------------------------------------------------
  32. The cluster health status is: `green`, `yellow` or `red`. On the shard
  33. level, a `red` status indicates that the specific shard is not allocated
  34. in the cluster, `yellow` means that the primary shard is allocated but
  35. replicas are not, and `green` means that all shards are allocated. The
  36. index level status is controlled by the worst shard status. The cluster
  37. status is controlled by the worst index status.
  38. One of the main benefits of the API is the ability to wait until the
  39. cluster reaches a certain high water-mark health level. For example, the
  40. following will wait for 50 seconds for the cluster to reach the `yellow`
  41. level (if it reaches the `green` or `yellow` status before 50 seconds elapse,
  42. it will return at that point):
  43. [source,js]
  44. --------------------------------------------------
  45. $ curl -XGET 'http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=50s'
  46. --------------------------------------------------
  47. [float]
  48. [[request-params]]
  49. === Request Parameters
  50. The cluster health API accepts the following request parameters:
  51. `level`::
  52. Can be one of `cluster`, `indices` or `shards`. Controls the
  53. details level of the health information returned. Defaults to `cluster`.
  54. `wait_for_status`::
  55. One of `green`, `yellow` or `red`. Will wait (until
  56. the timeout provided) until the status of the cluster changes to the one
  57. provided or better, i.e. `green` > `yellow` > `red`. By default, will not
  58. wait for any status.
  59. `wait_for_relocating_shards`::
  60. A number controlling to how many relocating
  61. shards to wait for. Usually will be `0` to indicate to wait till all
  62. relocations have happened. Defaults to not wait.
  63. `wait_for_active_shards`::
  64. A number controlling to how many active
  65. shards to wait for. Defaults to not wait.
  66. `wait_for_nodes`::
  67. The request waits until the specified number `N` of
  68. nodes is available. It also accepts `>=N`, `<=N`, `>N` and `<N`.
  69. Alternatively, it is possible to use `ge(N)`, `le(N)`, `gt(N)` and
  70. `lt(N)` notation.
  71. `timeout`::
  72. A time based parameter controlling how long to wait if one of
  73. the wait_for_XXX are provided. Defaults to `30s`.
  74. The following is an example of getting the cluster health at the
  75. `shards` level:
  76. [source,js]
  77. --------------------------------------------------
  78. $ curl -XGET 'http://localhost:9200/_cluster/health/twitter?level=shards'
  79. --------------------------------------------------