cat.asciidoc 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. [[cat]]
  2. == cat APIs
  3. ["float",id="intro"]
  4. === Introduction
  5. JSON is great... for computers. Even if it's pretty-printed, trying
  6. to find relationships in the data is tedious. Human eyes, especially
  7. when looking at a terminal, need compact and aligned text. The cat APIs
  8. aim to meet this need.
  9. [IMPORTANT]
  10. ====
  11. cat APIs are only intended for human consumption using the
  12. {kibana-ref}/console-kibana.html[Kibana console] or command line. They are _not_
  13. intended for use by applications. For application consumption, we recommend
  14. using a corresponding JSON API.
  15. ====
  16. All the cat commands accept a query string parameter `help` to see all
  17. the headers and info they provide, and the `/_cat` command alone lists all
  18. the available commands.
  19. [discrete]
  20. [[common-parameters]]
  21. === Common parameters
  22. [discrete]
  23. [[verbose]]
  24. ==== Verbose
  25. Each of the commands accepts a query string parameter `v` to turn on
  26. verbose output. For example:
  27. [source,console]
  28. --------------------------------------------------
  29. GET /_cat/master?v
  30. --------------------------------------------------
  31. Might respond with:
  32. [source,txt]
  33. --------------------------------------------------
  34. id host ip node
  35. u_n93zwxThWHi1PDBJAGAg 127.0.0.1 127.0.0.1 u_n93zw
  36. --------------------------------------------------
  37. // TESTRESPONSE[s/u_n93zw(xThWHi1PDBJAGAg)?/.+/ non_json]
  38. [discrete]
  39. [[help]]
  40. ==== Help
  41. Each of the commands accepts a query string parameter `help` which will
  42. output its available columns. For example:
  43. [source,console]
  44. --------------------------------------------------
  45. GET /_cat/master?help
  46. --------------------------------------------------
  47. Might respond with:
  48. [source,txt]
  49. --------------------------------------------------
  50. id | | node id
  51. host | h | host name
  52. ip | | ip address
  53. node | n | node name
  54. --------------------------------------------------
  55. // TESTRESPONSE[s/[|]/[|]/ non_json]
  56. NOTE: `help` is not supported if any optional url parameter is used.
  57. For example `GET _cat/shards/my-index-000001?help` or `GET _cat/indices/my-index-*?help`
  58. results in an error. Use `GET _cat/shards?help` or `GET _cat/indices?help`
  59. instead.
  60. [discrete]
  61. [[headers]]
  62. ==== Headers
  63. Each of the commands accepts a query string parameter `h` which forces
  64. only those columns to appear. For example:
  65. [source,console]
  66. --------------------------------------------------
  67. GET /_cat/nodes?h=ip,port,heapPercent,name
  68. --------------------------------------------------
  69. Responds with:
  70. [source,txt]
  71. --------------------------------------------------
  72. 127.0.0.1 9300 27 sLBaIGK
  73. --------------------------------------------------
  74. // TESTRESPONSE[s/9300 27 sLBaIGK/\\d+ \\d+ .+/ non_json]
  75. You can also request multiple columns using simple wildcards like
  76. `/_cat/thread_pool?h=ip,queue*` to get all headers (or aliases) starting
  77. with `queue`.
  78. [discrete]
  79. [[numeric-formats]]
  80. ==== Numeric formats
  81. Many commands provide a few types of numeric output, either a byte, size
  82. or a time value. By default, these types are human-formatted,
  83. for example, `3.5mb` instead of `3763212`. The human values are not
  84. sortable numerically, so in order to operate on these values where
  85. order is important, you can change it.
  86. Say you want to find the largest index in your cluster (storage used
  87. by all the shards, not number of documents). The `/_cat/indices` API
  88. is ideal. You only need to add three things to the API request:
  89. . The `bytes` query string parameter with a value of `b` to get byte-level resolution.
  90. . The `s` (sort) parameter with a value of `store.size:desc` to sort the output
  91. by shard storage in descending order.
  92. . The `v` (verbose) parameter to include column headings in the response.
  93. [source,console]
  94. --------------------------------------------------
  95. GET /_cat/indices?bytes=b&s=store.size:desc&v
  96. --------------------------------------------------
  97. // TEST[setup:my_index_huge]
  98. // TEST[s/^/PUT my-index-000002\n{"settings": {"number_of_replicas": 0}}\n/]
  99. The API returns the following response:
  100. [source,txt]
  101. --------------------------------------------------
  102. health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
  103. yellow open my-index-000001 u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 72171 72171
  104. green open my-index-000002 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 230 230
  105. --------------------------------------------------
  106. // TESTRESPONSE[s/72171|230/\\d+/]
  107. // TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json]
  108. // TESTRESPONSE[skip:"AwaitsFix https://github.com/elastic/elasticsearch/issues/51619"]
  109. If you want to change the <<time-units,time units>>, use `time` parameter.
  110. If you want to change the <<size-units,size units>>, use `size` parameter.
  111. If you want to change the <<byte-units,byte units>>, use `bytes` parameter.
  112. [discrete]
  113. ==== Response as text, json, smile, yaml or cbor
  114. [source,sh]
  115. --------------------------------------------------
  116. % curl 'localhost:9200/_cat/indices?format=json&pretty'
  117. [
  118. {
  119. "pri.store.size": "650b",
  120. "health": "yellow",
  121. "status": "open",
  122. "index": "my-index-000001",
  123. "pri": "5",
  124. "rep": "1",
  125. "docs.count": "0",
  126. "docs.deleted": "0",
  127. "store.size": "650b"
  128. }
  129. ]
  130. --------------------------------------------------
  131. // NOTCONSOLE
  132. Currently supported formats (for the `?format=` parameter):
  133. - text (default)
  134. - json
  135. - smile
  136. - yaml
  137. - cbor
  138. Alternatively you can set the "Accept" HTTP header to the appropriate media format.
  139. All formats above are supported, the GET parameter takes precedence over the header.
  140. For example:
  141. [source,sh]
  142. --------------------------------------------------
  143. % curl '192.168.56.10:9200/_cat/indices?pretty' -H "Accept: application/json"
  144. [
  145. {
  146. "pri.store.size": "650b",
  147. "health": "yellow",
  148. "status": "open",
  149. "index": "my-index-000001",
  150. "pri": "5",
  151. "rep": "1",
  152. "docs.count": "0",
  153. "docs.deleted": "0",
  154. "store.size": "650b"
  155. }
  156. ]
  157. --------------------------------------------------
  158. // NOTCONSOLE
  159. [discrete]
  160. [[sort]]
  161. ==== Sort
  162. Each of the commands accepts a query string parameter `s` which sorts the table by
  163. the columns specified as the parameter value. Columns are specified either by name or by
  164. alias, and are provided as a comma separated string. By default, sorting is done in
  165. ascending fashion. Appending `:desc` to a column will invert the ordering for
  166. that column. `:asc` is also accepted but exhibits the same behavior as the default sort order.
  167. For example, with a sort string `s=column1,column2:desc,column3`, the table will be
  168. sorted in ascending order by column1, in descending order by column2, and in ascending
  169. order by column3.
  170. [source,sh]
  171. --------------------------------------------------
  172. GET _cat/templates?v&s=order:desc,index_patterns
  173. --------------------------------------------------
  174. //CONSOLE
  175. returns:
  176. [source,txt]
  177. --------------------------------------------------
  178. name index_patterns order version
  179. pizza_pepperoni [*pepperoni*] 2
  180. sushi_california_roll [*avocado*] 1 1
  181. pizza_hawaiian [*pineapples*] 1
  182. --------------------------------------------------
  183. include::cat/alias.asciidoc[]
  184. include::cat/allocation.asciidoc[]
  185. include::cat/anomaly-detectors.asciidoc[]
  186. include::cat/count.asciidoc[]
  187. include::cat/dataframeanalytics.asciidoc[]
  188. include::cat/datafeeds.asciidoc[]
  189. include::cat/fielddata.asciidoc[]
  190. include::cat/health.asciidoc[]
  191. include::cat/indices.asciidoc[]
  192. include::cat/master.asciidoc[]
  193. include::cat/nodeattrs.asciidoc[]
  194. include::cat/nodes.asciidoc[]
  195. include::cat/pending_tasks.asciidoc[]
  196. include::cat/plugins.asciidoc[]
  197. include::cat/recovery.asciidoc[]
  198. include::cat/repositories.asciidoc[]
  199. include::cat/shards.asciidoc[]
  200. include::cat/segments.asciidoc[]
  201. include::cat/snapshots.asciidoc[]
  202. include::cat/tasks.asciidoc[]
  203. include::cat/templates.asciidoc[]
  204. include::cat/thread_pool.asciidoc[]
  205. include::cat/trainedmodel.asciidoc[]
  206. include::cat/transforms.asciidoc[]