4.2 KiB
layout, title, parent, nav_order, has_children, redirect_from
| layout | title | parent | nav_order | has_children | redirect_from | |
|---|---|---|---|---|---|---|
| default | CAT shards | CAT APIs | 60 | false |
|
CAT Shards API
Introduced 1.0 {: .label .label-purple }
The CAT shards operation lists the state of all primary and replica shards and how they are distributed.
Endpoints
GET /_cat/shards
GET /_cat/shards/{index}
Query parameters
The following table lists the available query parameters. All query parameters are optional.
| Parameter | Data type | Description | Default |
|---|---|---|---|
bytes |
String | The units used to display byte values. Valid values are: b, kb, k, mb, m, gb, g, tb, t, pb, and p. |
N/A |
cluster_manager_timeout |
String | The amount of time allowed to establish a connection to the cluster manager node. | N/A |
format |
String | A short version of the Accept header, such as json or yaml. Valid values are: cbor, json, smile, text, and yaml. |
text |
h |
List | A comma-separated list of column names to display. | N/A |
help |
Boolean | Returns help information. | false |
limit |
Integer | The maximum number of rows to return. Must be greater than 0. Applied after sorting (s). |
N/A |
local |
Boolean | Returns local information but does not retrieve the state from the cluster manager node. | false |
s |
List | A comma-separated list of column names or column aliases to sort by. | N/A |
time |
String | Specifies the time units, for example, 5d or 7h. For more information, see Supported units. Valid values are: nanos, micros, ms, s, m, h, and d. |
N/A |
v |
Boolean | Enables verbose mode, which displays column headers. | false |
Example requests
The following example requests returns information about shards:
{% capture step1_rest %} GET /_cat/shards?v {% endcapture %}
{% capture step1_python %}
response = client.cat.shards( params = { "v": "true" } )
{% endcapture %}
{% include code-block.html rest=step1_rest python=step1_python %}
To see only the information about shards of a specific index, add the index name after your query.
{% capture step1_rest %} GET /_cat/shards/?v {% endcapture %}
{% capture step1_python %}
response = client.cat.shards( index = "", params = { "v": "true" } )
{% endcapture %}
{% include code-block.html rest=step1_rest python=step1_python %}
If you want to get information for more than one index, separate the indexes with commas:
{% capture step1_rest %} GET /_cat/shards/index1,index2,index3 {% endcapture %}
{% capture step1_python %}
response = client.cat.shards( index = "index1,index2,index3" )
{% endcapture %}
{% include code-block.html rest=step1_rest python=step1_python %}
Example response
index | shard | prirep | state | docs | store | ip | | node
plugins | 0 | p | STARTED | 0 | 208b | 172.18.0.4 | odfe-node1
plugins | 0 | r | STARTED | 0 | 208b | 172.18.0.3 | odfe-node2
Limiting the response size
To limit the number of shards returned, configure the cat.shards.response.limit.number_of_shards setting. For more information, see Cluster-level CAT response limit settings.
Required permissions
If you use the Security plugin, make sure you have the appropriate permissions: indices:monitor/stats and cluster:monitor/state.