recovery.asciidoc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. [[indices-recovery]]
  2. === Index recovery API
  3. ++++
  4. <titleabbrev>Index recovery</titleabbrev>
  5. ++++
  6. Returns information about ongoing and completed shard recoveries for one or more
  7. indices. For data streams, the API returns information for the stream's backing
  8. indices.
  9. [source,console]
  10. ----
  11. GET /my-index-000001/_recovery
  12. ----
  13. // TEST[setup:my_index]
  14. [[index-recovery-api-request]]
  15. ==== {api-request-title}
  16. `GET /<target>/_recovery`
  17. `GET /_recovery`
  18. [[index-recovery-api-desc]]
  19. ==== {api-description-title}
  20. Use the index recovery API
  21. to get information about ongoing and completed shard recoveries.
  22. // tag::shard-recovery-desc[]
  23. Shard recovery is the process
  24. of syncing a replica shard from a primary shard.
  25. Upon completion,
  26. the replica shard is available for search.
  27. include::{es-repo-dir}/glossary.asciidoc[tag=recovery-triggers]
  28. // end::shard-recovery-desc[]
  29. [[index-recovery-api-path-params]]
  30. ==== {api-path-parms-title}
  31. `<target>`::
  32. (Optional, string)
  33. Comma-separated list of data streams, indices, and index aliases used to limit
  34. the request. Wildcard expressions (`*`) are supported.
  35. +
  36. To target all data streams and indices in a cluster, omit this parameter or use
  37. `_all` or `*`.
  38. [[index-recovery-api-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=detailed]
  42. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-query-parm]
  43. [[index-recovery-api-response-body]]
  44. ==== {api-response-body-title}
  45. `id`::
  46. (Integer)
  47. ID of the shard.
  48. `type`::
  49. +
  50. --
  51. (String)
  52. Recovery type.
  53. Returned values include:
  54. `STORE`::
  55. The recovery is related to
  56. a node startup or failure.
  57. This type of recovery is called a local store recovery.
  58. `SNAPSHOT`::
  59. The recovery is related to
  60. a <<snapshots-restore-snapshot,snapshot restoration>>.
  61. `REPLICA`::
  62. The recovery is related to
  63. a <<glossary-replica-shard,primary shard replication>>.
  64. `RELOCATING`::
  65. The recovery is related to
  66. the relocation of a shard
  67. to a different node in the same cluster.
  68. --
  69. `STAGE`::
  70. +
  71. --
  72. (String)
  73. Recovery stage.
  74. Returned values include:
  75. `DONE`::
  76. Complete.
  77. `FINALIZE`::
  78. Cleanup.
  79. `INDEX`::
  80. Reading index metadata and copying bytes from source to destination.
  81. `INIT`::
  82. Recovery has not started.
  83. `START`::
  84. Starting the recovery process; opening the index for use.
  85. `TRANSLOG`::
  86. Replaying transaction log .
  87. --
  88. `primary`::
  89. (Boolean)
  90. If `true`,
  91. the shard is a primary shard.
  92. `start_time`::
  93. (String)
  94. Timestamp of recovery start.
  95. `stop_time`::
  96. (String)
  97. Timestamp of recovery finish.
  98. `total_time_in_millis`::
  99. (String)
  100. Total time to recover shard in milliseconds.
  101. `source`::
  102. +
  103. --
  104. (Object)
  105. Recovery source.
  106. This can include:
  107. * A repository description if recovery is from a snapshot
  108. * A description of source node
  109. --
  110. `target`::
  111. (Object)
  112. Destination node.
  113. `index`::
  114. (Object)
  115. Statistics about physical index recovery.
  116. `translog`::
  117. (Object)
  118. Statistics about translog recovery.
  119. `start`::
  120. (Object)
  121. Statistics about time to open and start the index.
  122. [[index-recovery-api-example]]
  123. ==== {api-examples-title}
  124. [[index-recovery-api-multi-ex]]
  125. ===== Get recovery information for several data streams and indices
  126. [source,console]
  127. --------------------------------------------------
  128. GET index1,index2/_recovery?human
  129. --------------------------------------------------
  130. // TEST[s/^/PUT index1\nPUT index2\n/]
  131. [[index-recovery-api-all-ex]]
  132. ===== Get segment information for all data streams and indices in a cluster
  133. //////////////////////////
  134. Here we create a repository and snapshot index1 in
  135. order to restore it right after and prints out the
  136. index recovery result.
  137. [source,console]
  138. --------------------------------------------------
  139. # create the index
  140. PUT index1
  141. {"settings": {"index.number_of_shards": 1}}
  142. # create the repository
  143. PUT /_snapshot/my_repository
  144. {"type": "fs","settings": {"location": "recovery_asciidoc" }}
  145. # snapshot the index
  146. PUT /_snapshot/my_repository/snap_1?wait_for_completion=true
  147. {"indices": "index1"}
  148. # delete the index
  149. DELETE index1
  150. # and restore the snapshot
  151. POST /_snapshot/my_repository/snap_1/_restore?wait_for_completion=true
  152. --------------------------------------------------
  153. [source,console-result]
  154. --------------------------------------------------
  155. {
  156. "snapshot": {
  157. "snapshot": "snap_1",
  158. "indices": [
  159. "index1"
  160. ],
  161. "shards": {
  162. "total": 1,
  163. "failed": 0,
  164. "successful": 1
  165. }
  166. }
  167. }
  168. --------------------------------------------------
  169. //////////////////////////
  170. [source,console]
  171. --------------------------------------------------
  172. GET /_recovery?human
  173. --------------------------------------------------
  174. // TEST[continued]
  175. The API returns the following response:
  176. [source,console-result]
  177. --------------------------------------------------
  178. {
  179. "index1" : {
  180. "shards" : [ {
  181. "id" : 0,
  182. "type" : "SNAPSHOT",
  183. "stage" : "INDEX",
  184. "primary" : true,
  185. "start_time" : "2014-02-24T12:15:59.716",
  186. "start_time_in_millis": 1393244159716,
  187. "stop_time" : "0s",
  188. "stop_time_in_millis" : 0,
  189. "total_time" : "2.9m",
  190. "total_time_in_millis" : 175576,
  191. "source" : {
  192. "repository" : "my_repository",
  193. "snapshot" : "my_snapshot",
  194. "index" : "index1",
  195. "version" : "{version}",
  196. "restoreUUID": "PDh1ZAOaRbiGIVtCvZOMww"
  197. },
  198. "target" : {
  199. "id" : "ryqJ5lO5S4-lSFbGntkEkg",
  200. "host" : "my.fqdn",
  201. "transport_address" : "my.fqdn",
  202. "ip" : "10.0.1.7",
  203. "name" : "my_es_node"
  204. },
  205. "index" : {
  206. "size" : {
  207. "total" : "75.4mb",
  208. "total_in_bytes" : 79063092,
  209. "reused" : "0b",
  210. "reused_in_bytes" : 0,
  211. "recovered" : "65.7mb",
  212. "recovered_in_bytes" : 68891939,
  213. "percent" : "87.1%"
  214. },
  215. "files" : {
  216. "total" : 73,
  217. "reused" : 0,
  218. "recovered" : 69,
  219. "percent" : "94.5%"
  220. },
  221. "total_time" : "0s",
  222. "total_time_in_millis" : 0,
  223. "source_throttle_time" : "0s",
  224. "source_throttle_time_in_millis" : 0,
  225. "target_throttle_time" : "0s",
  226. "target_throttle_time_in_millis" : 0
  227. },
  228. "translog" : {
  229. "recovered" : 0,
  230. "total" : 0,
  231. "percent" : "100.0%",
  232. "total_on_start" : 0,
  233. "total_time" : "0s",
  234. "total_time_in_millis" : 0,
  235. },
  236. "verify_index" : {
  237. "check_index_time" : "0s",
  238. "check_index_time_in_millis" : 0,
  239. "total_time" : "0s",
  240. "total_time_in_millis" : 0
  241. }
  242. } ]
  243. }
  244. }
  245. --------------------------------------------------
  246. // TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
  247. // TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
  248. ////
  249. The TESTRESPONSE above replace all the fields values by the expected ones in the test,
  250. because we don't really care about the field values but we want to check the fields names.
  251. ////
  252. This response includes information
  253. about a single index recovering a single shard.
  254. The source of the recovery is a snapshot repository
  255. and the target of the recovery is the `my_es_node` node.
  256. The response also includes the number
  257. and percentage of files and bytes recovered.
  258. [[index-recovery-api-detailed-ex]]
  259. ===== Get detailed recovery information
  260. To get a list of physical files in recovery,
  261. set the `detailed` query parameter to `true`.
  262. [source,console]
  263. --------------------------------------------------
  264. GET _recovery?human&detailed=true
  265. --------------------------------------------------
  266. // TEST[s/^/PUT index1\n{"settings": {"index.number_of_shards": 1}}\n/]
  267. The API returns the following response:
  268. [source,console-result]
  269. --------------------------------------------------
  270. {
  271. "index1" : {
  272. "shards" : [ {
  273. "id" : 0,
  274. "type" : "STORE",
  275. "stage" : "DONE",
  276. "primary" : true,
  277. "start_time" : "2014-02-24T12:38:06.349",
  278. "start_time_in_millis" : "1393245486349",
  279. "stop_time" : "2014-02-24T12:38:08.464",
  280. "stop_time_in_millis" : "1393245488464",
  281. "total_time" : "2.1s",
  282. "total_time_in_millis" : 2115,
  283. "source" : {
  284. "id" : "RGMdRc-yQWWKIBM4DGvwqQ",
  285. "host" : "my.fqdn",
  286. "transport_address" : "my.fqdn",
  287. "ip" : "10.0.1.7",
  288. "name" : "my_es_node"
  289. },
  290. "target" : {
  291. "id" : "RGMdRc-yQWWKIBM4DGvwqQ",
  292. "host" : "my.fqdn",
  293. "transport_address" : "my.fqdn",
  294. "ip" : "10.0.1.7",
  295. "name" : "my_es_node"
  296. },
  297. "index" : {
  298. "size" : {
  299. "total" : "24.7mb",
  300. "total_in_bytes" : 26001617,
  301. "reused" : "24.7mb",
  302. "reused_in_bytes" : 26001617,
  303. "recovered" : "0b",
  304. "recovered_in_bytes" : 0,
  305. "percent" : "100.0%"
  306. },
  307. "files" : {
  308. "total" : 26,
  309. "reused" : 26,
  310. "recovered" : 0,
  311. "percent" : "100.0%",
  312. "details" : [ {
  313. "name" : "segments.gen",
  314. "length" : 20,
  315. "recovered" : 20
  316. }, {
  317. "name" : "_0.cfs",
  318. "length" : 135306,
  319. "recovered" : 135306
  320. }, {
  321. "name" : "segments_2",
  322. "length" : 251,
  323. "recovered" : 251
  324. }
  325. ]
  326. },
  327. "total_time" : "2ms",
  328. "total_time_in_millis" : 2,
  329. "source_throttle_time" : "0s",
  330. "source_throttle_time_in_millis" : 0,
  331. "target_throttle_time" : "0s",
  332. "target_throttle_time_in_millis" : 0
  333. },
  334. "translog" : {
  335. "recovered" : 71,
  336. "total" : 0,
  337. "percent" : "100.0%",
  338. "total_on_start" : 0,
  339. "total_time" : "2.0s",
  340. "total_time_in_millis" : 2025
  341. },
  342. "verify_index" : {
  343. "check_index_time" : 0,
  344. "check_index_time_in_millis" : 0,
  345. "total_time" : "88ms",
  346. "total_time_in_millis" : 88
  347. }
  348. } ]
  349. }
  350. }
  351. --------------------------------------------------
  352. // TESTRESPONSE[s/"source" : \{[^}]*\}/"source" : $body.$_path/]
  353. // TESTRESPONSE[s/"details" : \[[^\]]*\]/"details" : $body.$_path/]
  354. // TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
  355. // TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
  356. ////
  357. The TESTRESPONSE above replace all the fields values by the expected ones in the test,
  358. because we don't really care about the field values but we want to check the fields names.
  359. It also removes the "details" part which is important in this doc but really hard to test.
  360. ////
  361. The response includes a listing
  362. of any physical files recovered
  363. and their sizes.
  364. The response also includes timings in milliseconds
  365. of the various stages of recovery:
  366. * Index retrieval
  367. * Translog replay
  368. * Index start time
  369. This response indicates the recovery is `done`.
  370. All recoveries,
  371. whether ongoing or complete,
  372. are kept in the cluster state
  373. and may be reported on at any time.
  374. To only return information about ongoing recoveries,
  375. set the `active_only` query parameter to `true`.