cat.asciidoc 7.1 KB

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