cat.asciidoc 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. [[cat]]
  2. == Compact and aligned text (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 compact and
  8. aligned text (CAT) APIs 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=true
  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` and a comma with `index:asc` to sort the output
  91. by shard storage descending order and then index name in ascending 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,index:asc&v=true
  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. If you want to change the <<time-units,time units>>, use `time` parameter.
  109. If you want to change the <<size-units,size units>>, use `size` parameter.
  110. If you want to change the <<byte-units,byte units>>, use `bytes` parameter.
  111. [discrete]
  112. ==== Response as text, json, smile, yaml or cbor
  113. [source,sh]
  114. --------------------------------------------------
  115. % curl 'localhost:9200/_cat/indices?format=json&pretty'
  116. [
  117. {
  118. "pri.store.size": "650b",
  119. "health": "yellow",
  120. "status": "open",
  121. "index": "my-index-000001",
  122. "pri": "5",
  123. "rep": "1",
  124. "docs.count": "0",
  125. "docs.deleted": "0",
  126. "store.size": "650b"
  127. }
  128. ]
  129. --------------------------------------------------
  130. // NOTCONSOLE
  131. Currently supported formats (for the `?format=` parameter):
  132. - text (default)
  133. - json
  134. - smile
  135. - yaml
  136. - cbor
  137. Alternatively you can set the "Accept" HTTP header to the appropriate media format.
  138. All formats above are supported, the GET parameter takes precedence over the header.
  139. For example:
  140. [source,sh]
  141. --------------------------------------------------
  142. % curl '192.168.56.10:9200/_cat/indices?pretty' -H "Accept: application/json"
  143. [
  144. {
  145. "pri.store.size": "650b",
  146. "health": "yellow",
  147. "status": "open",
  148. "index": "my-index-000001",
  149. "pri": "5",
  150. "rep": "1",
  151. "docs.count": "0",
  152. "docs.deleted": "0",
  153. "store.size": "650b"
  154. }
  155. ]
  156. --------------------------------------------------
  157. // NOTCONSOLE
  158. [discrete]
  159. [[sort]]
  160. ==== Sort
  161. Each of the commands accepts a query string parameter `s` which sorts the table by
  162. the columns specified as the parameter value. Columns are specified either by name or by
  163. alias, and are provided as a comma separated string. By default, sorting is done in
  164. ascending fashion. Appending `:desc` to a column will invert the ordering for
  165. that column. `:asc` is also accepted but exhibits the same behavior as the default sort order.
  166. For example, with a sort string `s=column1,column2:desc,column3`, the table will be
  167. sorted in ascending order by column1, in descending order by column2, and in ascending
  168. order by column3.
  169. [source,sh]
  170. --------------------------------------------------
  171. GET _cat/templates?v=true&s=order:desc,index_patterns
  172. --------------------------------------------------
  173. //CONSOLE
  174. returns:
  175. [source,txt]
  176. --------------------------------------------------
  177. name index_patterns order version
  178. pizza_pepperoni [*pepperoni*] 2
  179. sushi_california_roll [*avocado*] 1 1
  180. pizza_hawaiian [*pineapples*] 1
  181. --------------------------------------------------
  182. include::cat/alias.asciidoc[]
  183. include::cat/allocation.asciidoc[]
  184. include::cat/anomaly-detectors.asciidoc[]
  185. include::cat/count.asciidoc[]
  186. include::cat/dataframeanalytics.asciidoc[]
  187. include::cat/datafeeds.asciidoc[]
  188. include::cat/fielddata.asciidoc[]
  189. include::cat/health.asciidoc[]
  190. include::cat/indices.asciidoc[]
  191. include::cat/master.asciidoc[]
  192. include::cat/nodeattrs.asciidoc[]
  193. include::cat/nodes.asciidoc[]
  194. include::cat/pending_tasks.asciidoc[]
  195. include::cat/plugins.asciidoc[]
  196. include::cat/recovery.asciidoc[]
  197. include::cat/repositories.asciidoc[]
  198. include::cat/segments.asciidoc[]
  199. include::cat/shards.asciidoc[]
  200. include::cat/snapshots.asciidoc[]
  201. include::cat/tasks.asciidoc[]
  202. include::cat/templates.asciidoc[]
  203. include::cat/thread_pool.asciidoc[]
  204. include::cat/trainedmodel.asciidoc[]
  205. include::cat/transforms.asciidoc[]