health.asciidoc 3.8 KB

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