shards.asciidoc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. [[cat-shards]]
  2. === cat shards API
  3. ++++
  4. <titleabbrev>cat shards</titleabbrev>
  5. ++++
  6. The `shards` command is the detailed view of what nodes contain which
  7. shards. It will tell you if it's a primary or replica, the number of
  8. docs, the bytes it takes on disk, and the node where it's located.
  9. [[cat-shards-api-request]]
  10. ==== {api-request-title}
  11. `GET /_cat/shards/<index>`
  12. `GET /_cat/shards`
  13. [[cat-shards-path-params]]
  14. ==== {api-path-parms-title}
  15. include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
  16. [[cat-shards-query-params]]
  17. ==== {api-query-parms-title}
  18. include::{docdir}/rest-api/common-parms.asciidoc[tag=bytes]
  19. include::{docdir}/rest-api/common-parms.asciidoc[tag=http-format]
  20. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-h]
  21. +
  22. --
  23. If you do not specify which columns to include, the API returns the default
  24. columns in the order listed below. If you explicitly specify one or more
  25. columns, it only returns the specified columns.
  26. Valid columns are:
  27. `index`, `i`, `idx`::
  28. (Default) Name of the index, such as `twitter`.
  29. `shard`, `s`, `sh`::
  30. (Default) Name of the shard.
  31. `prirep`, `p`, `pr`, `primaryOrReplica`::
  32. (Default) Shard type. Returned values are `primary` or `replica`.
  33. `state`, `st`::
  34. (Default) State of the shard. Returned values are:
  35. +
  36. * `INITIALIZING`: The shard is recovering from a peer shard or gateway.
  37. * `RELOCATING`: The shard is relocating.
  38. * `STARTED`: The shard has started.
  39. * `UNASSIGNED`: The shard is not assigned to any node.
  40. `docs`, `d`, `dc`::
  41. (Default) Number of documents in shard, such as `25`.
  42. `store`, `sto`::
  43. (Default) Disk space used by the shard, such as `5kb`.
  44. `ip`::
  45. (Default) IP address of the node, such as `127.0.1.1`.
  46. `id`::
  47. (Default) ID of the node, such as `k0zy`.
  48. `node`, `n`::
  49. (Default) Node name, such as `I8hydUG`.
  50. `completion.size`, `cs`, `completionSize`::
  51. Size of completion, such as `0b`.
  52. `fielddata.memory_size`, `fm`, `fielddataMemory`::
  53. Used fielddata cache memory, such as `0b`.
  54. `fielddata.evictions`, `fe`, `fielddataEvictions`::
  55. Fielddata cache evictions, such as `0`.
  56. `flush.total`, `ft`, `flushTotal`::
  57. Number of flushes, such as `1`.
  58. `flush.total_time`, `ftt`, `flushTotalTime`::
  59. Time spent in flush, such as `1`.
  60. `get.current`, `gc`, `getCurrent`::
  61. Number of current get operations, such as `0`.
  62. `get.time`, `gti`, `getTime`::
  63. Time spent in get, such as `14ms`.
  64. `get.total`, `gto`, `getTotal`::
  65. Number of get operations, such as `2`.
  66. `get.exists_time`, `geti`, `getExistsTime`::
  67. Time spent in successful gets, such as `14ms`.
  68. `get.exists_total`, `geto`, `getExistsTotal`::
  69. Number of successful get operations, such as `2`.
  70. `get.missing_time`, `gmti`, `getMissingTime`::
  71. Time spent in failed gets, such as `0s`.
  72. `get.missing_total`, `gmto`, `getMissingTotal`::
  73. Number of failed get operations, such as `1`.
  74. `indexing.delete_current`, `idc`, `indexingDeleteCurrent`::
  75. Number of current deletion operations, such as `0`.
  76. `indexing.delete_time`, `idti`, `indexingDeleteTime`::
  77. Time spent in deletions, such as `2ms`.
  78. `indexing.delete_total`, `idto`, `indexingDeleteTotal`::
  79. Number of deletion operations, such as `2`.
  80. `indexing.index_current`, `iic`, `indexingIndexCurrent`::
  81. Number of current indexing operations, such as `0`.
  82. `indexing.index_time`, `iiti`, `indexingIndexTime`::
  83. Time spent in indexing, such as `134ms`.
  84. `indexing.index_total`, `iito`, `indexingIndexTotal`::
  85. Number of indexing operations, such as `1`.
  86. `indexing.index_failed`, `iif`, `indexingIndexFailed`::
  87. Number of failed indexing operations, such as `0`.
  88. `merges.current`, `mc`, `mergesCurrent`::
  89. Number of current merge operations, such as `0`.
  90. `merges.current_docs`, `mcd`, `mergesCurrentDocs`::
  91. Number of current merging documents, such as `0`.
  92. `merges.current_size`, `mcs`, `mergesCurrentSize`::
  93. Size of current merges, such as `0b`.
  94. `merges.total`, `mt`, `mergesTotal`::
  95. Number of completed merge operations, such as `0`.
  96. `merges.total_docs`, `mtd`, `mergesTotalDocs`::
  97. Number of merged documents, such as `0`.
  98. `merges.total_size`, `mts`, `mergesTotalSize`::
  99. Size of current merges, such as `0b`.
  100. `merges.total_time`, `mtt`, `mergesTotalTime`::
  101. Time spent merging documents, such as `0s`.
  102. `query_cache.memory_size`, `qcm`, `queryCacheMemory`::
  103. Used query cache memory, such as `0b`.
  104. `query_cache.evictions`, `qce`, `queryCacheEvictions`::
  105. Query cache evictions, such as `0`.
  106. `recoverysource.type`, `rs`::
  107. Type of recovery source.
  108. `refresh.total`, `rto`, `refreshTotal`::
  109. Number of refreshes, such as `16`.
  110. `refresh.time`, `rti`, `refreshTime`::
  111. Time spent in refreshes, such as `91ms`.
  112. `search.fetch_current`, `sfc`, `searchFetchCurrent`::
  113. Current fetch phase operations, such as `0`.
  114. `search.fetch_time`, `sfti`, `searchFetchTime`::
  115. Time spent in fetch phase, such as `37ms`.
  116. `search.fetch_total`, `sfto`, `searchFetchTotal`::
  117. Number of fetch operations, such as `7`.
  118. `search.open_contexts`, `so`, `searchOpenContexts`::
  119. Open search contexts, such as `0`.
  120. `search.query_current`, `sqc`, `searchQueryCurrent`::
  121. Current query phase operations, such as `0`.
  122. `search.query_time`, `sqti`, `searchQueryTime`::
  123. Time spent in query phase, such as `43ms`.
  124. `search.query_total`, `sqto`, `searchQueryTotal`::
  125. Number of query operations, such as `9`.
  126. `search.scroll_current`, `scc`, `searchScrollCurrent`::
  127. Open scroll contexts, such as `2`.
  128. `search.scroll_time`, `scti`, `searchScrollTime`::
  129. Time scroll contexts held open, such as `2m`.
  130. `search.scroll_total`, `scto`, `searchScrollTotal`::
  131. Completed scroll contexts, such as `1`.
  132. `segments.count`, `sc`, `segmentsCount`::
  133. Number of segments, such as `4`.
  134. `segments.memory`, `sm`, `segmentsMemory`::
  135. Memory used by segments, such as `1.4kb`.
  136. `segments.index_writer_memory`, `siwm`, `segmentsIndexWriterMemory`::
  137. Memory used by index writer, such as `18mb`.
  138. `segments.version_map_memory`, `svmm`, `segmentsVersionMapMemory`::
  139. Memory used by version map, such as `1.0kb`.
  140. `segments.fixed_bitset_memory`, `sfbm`, `fixedBitsetMemory`::
  141. Memory used by fixed bit sets for nested object field types and type filters for
  142. types referred in <<parent-join,`join`>> fields, such as `1.0kb`.
  143. `seq_no.global_checkpoint`, `sqg`, `globalCheckpoint`::
  144. Global checkpoint.
  145. `seq_no.local_checkpoint`, `sql`, `localCheckpoint`::
  146. Local checkpoint.
  147. `seq_no.max`, `sqm`, `maxSeqNo`::
  148. Maximum sequence number.
  149. `suggest.current`, `suc`, `suggestCurrent`::
  150. Number of current suggest operations, such as `0`.
  151. `suggest.time`, `suti`, `suggestTime`::
  152. Time spent in suggest, such as `0`.
  153. `suggest.total`, `suto`, `suggestTotal`::
  154. Number of suggest operations, such as `0`.
  155. `sync_id`::
  156. Sync ID of the shard.
  157. `unassigned.at`, `ua`::
  158. Time at which the shard became unassigned in
  159. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets[Coordinated Universal
  160. Time (UTC)].
  161. `unassigned.details`, `ud`::
  162. Details about why the shard became unassigned.
  163. `unassigned.for`, `uf`::
  164. Time at which the shard was requested to be unassigned in
  165. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets[Coordinated Universal
  166. Time (UTC)].
  167. [[reason-unassigned]]
  168. `unassigned.reason`, `ur`::
  169. Reason the shard is unassigned. Returned values are:
  170. +
  171. * `ALLOCATION_FAILED`: Unassigned as a result of a failed allocation of the shard.
  172. * `CLUSTER_RECOVERED`: Unassigned as a result of a full cluster recovery.
  173. * `DANGLING_INDEX_IMPORTED`: Unassigned as a result of importing a dangling index.
  174. * `EXISTING_INDEX_RESTORED`: Unassigned as a result of restoring into a closed index.
  175. * `INDEX_CREATED`: Unassigned as a result of an API creation of an index.
  176. * `INDEX_REOPENED`: Unassigned as a result of opening a closed index.
  177. * `NEW_INDEX_RESTORED`: Unassigned as a result of restoring into a new index.
  178. * `NODE_LEFT`: Unassigned as a result of the node hosting it leaving the cluster.
  179. * `REALLOCATED_REPLICA`: A better replica location is identified and causes the existing replica allocation to be cancelled.
  180. * `REINITIALIZED`: When a shard moves from started back to initializing.
  181. * `REPLICA_ADDED`: Unassigned as a result of explicit addition of a replica.
  182. * `REROUTE_CANCELLED`: Unassigned as a result of explicit cancel reroute command.
  183. --
  184. include::{docdir}/rest-api/common-parms.asciidoc[tag=help]
  185. include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
  186. include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  187. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-s]
  188. include::{docdir}/rest-api/common-parms.asciidoc[tag=time]
  189. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-v]
  190. [[cat-shards-api-example]]
  191. ==== {api-examples-title}
  192. [[cat-shards-api-example-single]]
  193. ===== Example with a single index
  194. [source,console]
  195. ---------------------------------------------------------------------------
  196. GET _cat/shards
  197. ---------------------------------------------------------------------------
  198. // TEST[setup:twitter]
  199. The API returns the following response:
  200. [source,txt]
  201. ---------------------------------------------------------------------------
  202. twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
  203. ---------------------------------------------------------------------------
  204. // TESTRESPONSE[s/3014/\\d+/]
  205. // TESTRESPONSE[s/31.1mb/\\d+(\.\\d+)?[kmg]?b/]
  206. // TESTRESPONSE[s/192.168.56.10/.*/]
  207. // TESTRESPONSE[s/H5dfFeA/node-0/ non_json]
  208. [[cat-shards-api-example-wildcard]]
  209. ===== Example with a index wildcard pattern
  210. If your cluster has many shards, you can use a wildcard pattern in the `{index}`
  211. path parameter to limit the API request.
  212. The following request returns information for any indices beginning with
  213. `twitt`.
  214. [source,console]
  215. ---------------------------------------------------------------------------
  216. GET _cat/shards/twitt*
  217. ---------------------------------------------------------------------------
  218. // TEST[setup:twitter]
  219. The API returns the following response:
  220. [source,txt]
  221. ---------------------------------------------------------------------------
  222. twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
  223. ---------------------------------------------------------------------------
  224. // TESTRESPONSE[s/3014/\\d+/]
  225. // TESTRESPONSE[s/31.1mb/\\d+(\.\\d+)?[kmg]?b/]
  226. // TESTRESPONSE[s/192.168.56.10/.*/]
  227. // TESTRESPONSE[s/H5dfFeA/node-0/ non_json]
  228. [[relocation]]
  229. ===== Example with a relocating shard
  230. [source,console]
  231. ---------------------------------------------------------------------------
  232. GET _cat/shards
  233. ---------------------------------------------------------------------------
  234. // TEST[skip:for now, relocation cannot be recreated]
  235. The API returns the following response:
  236. [source,txt]
  237. ---------------------------------------------------------------------------
  238. twitter 0 p RELOCATING 3014 31.1mb 192.168.56.10 H5dfFeA -> -> 192.168.56.30 bGG90GE
  239. ---------------------------------------------------------------------------
  240. // TESTRESPONSE[non_json]
  241. The `RELOCATING` value in `state` column indicates the index shard is
  242. relocating.
  243. [[states]]
  244. ===== Example with a shard states
  245. Before a shard is available for use, it goes through an `INITIALIZING` state.
  246. You can use the cat shards API to see which shards are initializing.
  247. [source,console]
  248. ---------------------------------------------------------------------------
  249. GET _cat/shards
  250. ---------------------------------------------------------------------------
  251. // TEST[skip:there is no guarantee to test for shards in initializing state]
  252. The API returns the following response:
  253. [source,txt]
  254. ---------------------------------------------------------------------------
  255. twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
  256. twitter 0 r INITIALIZING 0 14.3mb 192.168.56.30 bGG90GE
  257. ---------------------------------------------------------------------------
  258. // TESTRESPONSE[non_json]
  259. ===== Example with reasons for unassigned shards
  260. The following request returns the `unassigned.reason` column, which indicates
  261. why a shard is unassigned.
  262. [source,console]
  263. ---------------------------------------------------------------------------
  264. GET _cat/shards?h=index,shard,prirep,state,unassigned.reason
  265. ---------------------------------------------------------------------------
  266. // TEST[skip:for now]
  267. The API returns the following response:
  268. [source,txt]
  269. ---------------------------------------------------------------------------
  270. twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
  271. twitter 0 r STARTED 3014 31.1mb 192.168.56.30 bGG90GE
  272. twitter 0 r STARTED 3014 31.1mb 192.168.56.20 I8hydUG
  273. twitter 0 r UNASSIGNED ALLOCATION_FAILED
  274. ---------------------------------------------------------------------------
  275. // TESTRESPONSE[non_json]