shards.asciidoc 13 KB

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