recovery.asciidoc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. [[cat-recovery]]
  2. === cat recovery API
  3. ++++
  4. <titleabbrev>cat recovery</titleabbrev>
  5. ++++
  6. [IMPORTANT]
  7. ====
  8. cat APIs are only intended for human consumption using the command line or {kib}
  9. console. They are _not_ intended for use by applications. For application
  10. consumption, use the <<indices-recovery,index recovery API>>.
  11. ====
  12. Returns information about ongoing and completed shard recoveries,
  13. similar to the <<indices-recovery, index recovery>> API.
  14. For data streams, the API returns information about the stream's backing
  15. indices.
  16. [[cat-recovery-api-request]]
  17. ==== {api-request-title}
  18. `GET /_cat/recovery/<target>`
  19. `GET /_cat/recovery`
  20. [[cat-recovery-api-prereqs]]
  21. ==== {api-prereq-title}
  22. * If the {es} {security-features} are enabled, you must have the `monitor` or
  23. `manage` <<privileges-list-cluster,cluster privilege>> to use this API. You must
  24. also have the `monitor` or `manage` <<privileges-list-indices,index privilege>>
  25. for any data stream, index, or alias you retrieve.
  26. [[cat-recovery-api-desc]]
  27. ==== {api-description-title}
  28. The cat recovery API returns information about shard recoveries, both
  29. ongoing and completed. It is a more compact view of the JSON
  30. <<indices-recovery,index recovery>> API.
  31. include::{es-repo-dir}/indices/recovery.asciidoc[tag=shard-recovery-desc]
  32. [[cat-recovery-path-params]]
  33. ==== {api-path-parms-title}
  34. `<target>`::
  35. (Optional, string) Comma-separated list of data streams, indices, and aliases
  36. used to limit the request. Supports wildcards (`*`). To target all data streams
  37. and indices, omit this parameter or use `*` or `_all`.
  38. [[cat-recovery-query-params]]
  39. ==== {api-query-parms-title}
  40. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=active-only]
  41. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=bytes]
  42. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=detailed]
  43. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=http-format]
  44. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-h]
  45. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]
  46. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-query-parm]
  47. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-s]
  48. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=time]
  49. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-v]
  50. [[cat-recovery-api-example]]
  51. ==== {api-examples-title}
  52. [[cat-recovery-api-ex-dead]]
  53. ===== Example with no ongoing recoveries
  54. [source,console]
  55. ----------------------------------------------------------------------------
  56. GET _cat/recovery?v=true
  57. ----------------------------------------------------------------------------
  58. // TEST[setup:my_index]
  59. The API returns the following response:
  60. [source,txt]
  61. ---------------------------------------------------------------------------
  62. index shard time type stage source_host source_node target_host target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percent
  63. my-index-000001 0 13ms store done n/a n/a 127.0.0.1 node-0 n/a n/a 0 0 100% 13 0b 0b 100% 9928b 0 0 100.0%
  64. ---------------------------------------------------------------------------
  65. // TESTRESPONSE[s/store/empty_store/]
  66. // TESTRESPONSE[s/100%/0.0%/]
  67. // TESTRESPONSE[s/9928b/0b/]
  68. // TESTRESPONSE[s/13ms/[0-9.]+m?s/]
  69. // TESTRESPONSE[s/13/\\d+/ non_json]
  70. In this example response, the source and target nodes are the same because the
  71. recovery type is `store`, meaning they were read from local storage on node
  72. start.
  73. [[cat-recovery-api-ex-live]]
  74. ===== Example with a live shard recovery
  75. By increasing the replica count of an index and bringing another node online to
  76. host the replicas, you can retrieve information about an ongoing recovery.
  77. [source,console]
  78. ----------------------------------------------------------------------------
  79. GET _cat/recovery?v=true&h=i,s,t,ty,st,shost,thost,f,fp,b,bp
  80. ----------------------------------------------------------------------------
  81. // TEST[setup:my_index]
  82. The API returns the following response:
  83. [source,txt]
  84. ----------------------------------------------------------------------------
  85. i s t ty st shost thost f fp b bp
  86. my-index-000001 0 1252ms peer done 192.168.1.1 192.168.1.2 0 100.0% 0b 100.0%
  87. ----------------------------------------------------------------------------
  88. // TESTRESPONSE[s/peer/empty_store/]
  89. // TESTRESPONSE[s/192.168.1.2/127.0.0.1/]
  90. // TESTRESPONSE[s/192.168.1.1/n\/a/]
  91. // TESTRESPONSE[s/100.0%/0.0%/]
  92. // TESTRESPONSE[s/1252ms/[0-9.]+m?s/ non_json]
  93. In this example response, the recovery type is `peer`, meaning the shard
  94. recovered from another node. The returned files and bytes are real-time
  95. measurements.
  96. [[cat-recovery-api-ex-snapshot]]
  97. ===== Example with a snapshot recovery
  98. You can restore backups of an index using the <<modules-snapshots,snapshot and
  99. restore>> API. You can use the cat recovery API retrieve information about a
  100. snapshot recovery.
  101. [source,console]
  102. --------------------------------------------------------------------------------
  103. GET _cat/recovery?v=true&h=i,s,t,ty,st,rep,snap,f,fp,b,bp
  104. --------------------------------------------------------------------------------
  105. // TEST[skip:no need to execute snapshot/restore here]
  106. The API returns the following response with a recovery type of `snapshot`:
  107. [source,txt]
  108. --------------------------------------------------------------------------------
  109. i s t ty st rep snap f fp b bp
  110. my-index-000001 0 1978ms snapshot done my-repo snap-1 79 8.0% 12086 9.0%
  111. --------------------------------------------------------------------------------
  112. // TESTRESPONSE[non_json]