Elastīgā meklēšana

Elasticsearch Shard List

Elasticsearch Shard List
Elasticsearch's cat API is very handy because it allows users to view information related to various Elasticsearch engine resources in Compact and Aligned Text (CAT).

This tutorial will show you how to use the _cat API to view information about shards in an Elasticsearch cluster, what node the replica is, the size it takes up the disk, and more.

How to List All Shards in a Cluster

To view all the shards in an Elasticsearch cluster, you can use the GE request at the _cat/shards API endpoint, as follows:

GET _cat/shards

If you are a cURL user, use the following command:

curl -XGET “http://localhost:9200/_cat/shards”

Executing the above command will give you information about all the shards in the cluster, as shown below (output truncated):

kibana_sample_data_flights 0 p STARTED 13059 5.3mb 172.28.86.133 instance-0000000003
kibana_sample_data_flights 0 r STARTED 13059 5.3mb 172.28.27.142 instance-0000000001
.slm-history-3-000001 0 p STARTED 172.28.86.133 instance-0000000003
.slm-history-3-000001 0 r STARTED 172.28.27.142 instance-0000000001
destination_index 0 p STARTED 13232 5.9mb 172.28.27.142 instance-0000000001
.monitoring-es-7-2021.01.22 0 p STARTED 279515 153.5mb 172.28.86.133 instance-0000000003
.monitoring-es-7-2021.01.22 0 r STARTED 279467 268.5mb 172.28.27.142 instance-0000000001
.kibana_task_manager_1 0 p STARTED 6 205.6kb 172.28.86.133 instance-0000000003
.kibana_task_manager_1 0 r STARTED 6 871.5kb 172.28.27.142 instance-0000000001
.monitoring-beats-7-2021.01.22 0 p STARTED 6245 8mb 172.28.86.133 instance-0000000003
--------------------------------output truncated---------------------

You can also filter the output and specify the format of the result. For example, to obtain the output in YAML format, add the format=yaml parameter to the request, as follows:

GET _cat/shards?format=yaml

The cURL command for this is:

curl -XGET “http://localhost:9200/_cat/shards?format=yaml”

The output should in YAML format as:

- index: "apm-7.10.2-onboarding-2021.01.20"
shard: "0"
prirep: "p"
state: "STARTED"
docs: "2"
store: "14.7kb"
ip: "172.28.27.142"
node: "instance-0000000001"
- index: "source_index"
shard: "0"
prirep: "p"
state: "STARTED"
docs: "0"
store: "208b"
ip: "172.28.86.133"
node: "instance-0000000003"
- index: "kibana_sample_type_diff"
shard: "0"
prirep: "p"
state: "STARTED"
docs: "13059"
store: "5.7mb"
ip: "172.28.86.133"
node: "instance-0000000003"
- index: "kibana_sample_type_diff"
shard: "0"
prirep: "r"
state: "STARTED"
docs: "13059"
store: "9.8mb"
ip: "172.28.27.142"
node: "instance-0000000001"
--------------------------------OUTPUT TRUNCATED---------------------

You can even choose to obtain specific headers. For example, to obtain the index name, shard name, shard state, shard disk space, node id, and node IP, filter by passing them to the header argument as:

GET _cat/shards?h=index,shard,state,store,id,ip&format=json

The cURL command is as follows:

curl -XGET “http://localhost:9200/_cat/shards?h=index,shard,state,store,id,ip&format=json”

Executing the above command gives you selected information about the shards in the JSON format. Skip the format parameters to use the default tabular format.

[

"index" : "kibana_sample_data_flights",
"shard" : "0",
"state" : "STARTED",
"store" : "5.3mb",
"id" : "gSlMjTKyTemoOX-EO7Em4w",
"ip" : "172.28.86.133"
,

"index" : "kibana_sample_data_flights",
"shard" : "0",
"state" : "STARTED",
"store" : "5.3mb",
"id" : "FTd_2iXjSXudN_Ua4tZhHg",
"ip" : "172.28.27.142"
,

"index" : ".slm-history-3-000001",
"shard" : "0",
"state" : "STARTED",
"store" : null,
"id" : "gSlMjTKyTemoOX-EO7Em4w",
"ip" : "172.28.86.133"
,

"index" : ".slm-history-3-000001",
"shard" : "0",
"state" : "STARTED",
"store" : null,
"id" : "FTd_2iXjSXudN_Ua4tZhHg",
"ip" : "172.28.27.142"
,

"index" : "destination_index",
"shard" : "0",
"state" : "STARTED",
"store" : "5.9mb",
"id" : "FTd_2iXjSXudN_Ua4tZhHg",
"ip" : "172.28.27.142"
,

"index" : ".monitoring-es-7-2021.01.22",
"shard" : "0",
"state" : "STARTED",
"store" : "154.7mb",
"id" : "gSlMjTKyTemoOX-EO7Em4w",
"ip" : "172.28.86.133"
,

"index" : ".monitoring-es-7-2021.01.22",
"shard" : "0",
"state" : "STARTED",
"store" : "270.2mb",
"id" : "FTd_2iXjSXudN_Ua4tZhHg",
"ip" : "172.28.27.142"
,
-----------------------------------OUTPUT TRUNCATED-------------------------

Shard Information for Specific Indices

T0 0btain information about a shard for a specific index, pass the name of the index as follows:

GET _cat/shards/kibana_sample_data_flights

Input the cURL command as follows:

curl -XGET “http://localhost:9200/_cat/shards/kibana_sample_data_flights”

This command gives you information about the shards of that specific index:

kibana_sample_data_flights 0 p STARTED 13059 5.3mb 172.28.86.133 instance-0000000003
kibana_sample_data_flights 0 r STARTED 13059 5.3mb 172.28.27.142 instance-0000000001

NOTE: You can also use parameters to filter the data above.

Conclusion

In this guide, we showed you how to use the cat API to obtain information about shards running in the Elasticsearch cluster.

Rakstot Windows 10, kursors lec vai pārvietojas nejauši
Ja atklājat, ka peles kursors automātiski, nejauši lec vai pārvietojas pats, rakstot Windows klēpjdatorā vai datorā, daži no šiem ieteikumiem var palī...
Kā mainīt peles un skārienpaliktņu ritināšanas virzienu operētājsistēmā Windows 10
Pele un SkārienpaliktnisTas ne tikai padara skaitļošanu vienkāršu, bet arī efektīvāku un mazāk laikietilpīgu. Mēs nevaram iedomāties dzīvi bez šīm ier...
Kā mainīt peles rādītāja un kursora izmēru, krāsu un shēmu operētājsistēmā Windows 10
Peles rādītājs un kursors operētājsistēmā Windows 10 ir ļoti svarīgi operētājsistēmas aspekti. To var teikt arī par citām operētājsistēmām, tāpēc pati...