recovery.asciidoc 5.6 KB

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