1
0

cat.asciidoc 6.6 KB

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