health.asciidoc 3.9 KB

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