How to check the status of an Elasticsearch cluster?

I tried to check it with

curl -XGET 'http://localhost:9200/_cluster/health' 

but nothing happened. He seems to be waiting for something. The console did not return. I had to kill him with CTRL + C.

I also tried to check existing indexes with

 curl -XGET 'http://localhost:9200/_cat/indices?v' 

Same behavior as above.

+16
source share
5 answers

To check the status of an elasticsearch cluster you need to use

 curl localhost:9200/_cat/health 

Learn more about cat APIs here .

I usually use the elasticsearch-head plugin to visualize this.

You can find the github project here.

It is easy to install sudo $ES_HOME/bin/plugin -i mobz/elasticsearch-head and then you can open localhost:9200/_plugin/head/ in your web browser.

You should have the following:

enter image description here

+22
source

You can check the status of the elasticsearch cluster using the (CURL) and Cluster APIs that have been verified by elasticsearch:

 $ curl -XGET 'localhost:9200/_cluster/health?pretty' 

This will give you status and other relevant data.

 { "cluster_name" : "xxxxxxxx", "status" : "green", "timed_out" : false, "number_of_nodes" : 2, "number_of_data_nodes" : 2, "active_primary_shards" : 15, "active_shards" : 12, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0 } 
+21
source

PROBLEM: -

Sometimes Localhost may not be solved. So it tends to return output as shown below:

# curl -XGET localhost: 9200 / _cluster / health? pretty

 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <title>ERROR: The requested URL could not be retrieved</title> <style type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></style> </head><body> <h1>ERROR</h1> <h2>The requested URL could not be retrieved</h2> <hr> <p>The following error was encountered while trying to retrieve the URL: <a href="http://localhost:9200/_cluster/health?">http://localhost:9200/_cluster/health?</a></p> <blockquote> <p><b>Connection to 127.0.0.1 failed.</b></p> </blockquote> <p>The system returned: <i>(111) Connection refused</i></p> <p>The remote host or network may be down. Please try the request again.</p> <p>Your cache administrator is <a href="mailto:root?subject=CacheErrorInfo%20-%20ERR_CONNECT_FAIL&amp;body=CacheHost%3A%20squid2%0D%0AErrPage%3A%20ERR_CONNECT_FAIL%0D%0AErr%3A%20(111)%20Connection%20refused%0D%0ATimeStamp%3A%20Mon,%2017%20Dec%202018%2008%3A07%3A36%20GMT%0D%0A%0D%0AClientIP%3A%20192.168.13.14%0D%0AServerIP%3A%20127.0.0.1%0D%0A%0D%0AHTTP%20Request%3A%0D%0AGET%20%2F_cluster%2Fhealth%3Fpretty%20HTTP%2F1.1%0AUser-Agent%3A%20curl%2F7.29.0%0D%0AHost%3A%20localhost%3A9200%0D%0AAccept%3A%20*%2F*%0D%0AProxy-Connection%3A%20Keep-Alive%0D%0A%0D%0A%0D%0A">root</a>.</p> <br> <hr> <div id="footer">Generated Mon, 17 Dec 2018 08:07:36 GMT by squid2 (squid/3.0.STABLE25)</div> </body></html> 

# curl -XGET localhost: 9200 / _cat / indices

 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <title>ERROR: The requested URL could not be retrieved</title> <style type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></style> </head><body> <h1>ERROR</h1> <h2>The requested URL could not be retrieved</h2> <hr> <p>The following error was encountered while trying to retrieve the URL: <a href="http://localhost:9200/_cat/indices">http://localhost:9200/_cat/indices</a></p> <blockquote> <p><b>Connection to 127.0.0.1 failed.</b></p> </blockquote> <p>The system returned: <i>(111) Connection refused</i></p> <p>The remote host or network may be down. Please try the request again.</p> <p>Your cache administrator is <a href="mailto:root?subject=CacheErrorInfo%20-%20ERR_CONNECT_FAIL&amp;body=CacheHost%3A%20squid2%0D%0AErrPage%3A%20ERR_CONNECT_FAIL%0D%0AErr%3A%20(111)%20Connection%20refused%0D%0ATimeStamp%3A%20Mon,%2017%20Dec%202018%2008%3A10%3A09%20GMT%0D%0A%0D%0AClientIP%3A%20192.168.13.14%0D%0AServerIP%3A%20127.0.0.1%0D%0A%0D%0AHTTP%20Request%3A%0D%0AGET%20%2F_cat%2Findices%20HTTP%2F1.1%0AUser-Agent%3A%20curl%2F7.29.0%0D%0AHost%3A%20localhost%3A9200%0D%0AAccept%3A%20*%2F*%0D%0AProxy-Connection%3A%20Keep-Alive%0D%0A%0D%0A%0D%0A">root</a>.</p> <br> <hr> <div id="footer">Generated Mon, 17 Dec 2018 08:10:09 GMT by squid2 (squid/3.0.STABLE25)</div> </body></html> 

DECISION :-

I think this error is most likely returned by the local Squid deployed on the server.

Thus, everything worked well after replacing localhost with local_ip in which ElasticSearch was deployed.

0
source

The _cluster/health API can do much more than the typical output that most see with it:

  $ curl -XGET 'localhost:9200/_cluster/health?pretty' 

Most APIs in Elasticsearch can use various arguments to increase their output. This also applies to the Cluster Health API .

Examples

all health indicators
 $ curl -XGET 'localhost:9200/_cluster/health?level=indices&pretty' | head -50 { "cluster_name" : "rdu-es-01", "status" : "green", "timed_out" : false, "number_of_nodes" : 9, "number_of_data_nodes" : 6, "active_primary_shards" : 1106, "active_shards" : 2213, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0, "indices" : { "filebeat-6.5.1-2019.06.10" : { "status" : "green", "number_of_shards" : 3, "number_of_replicas" : 1, "active_primary_shards" : 3, "active_shards" : 6, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 }, "filebeat-6.5.1-2019.06.11" : { "status" : "green", "number_of_shards" : 3, "number_of_replicas" : 1, "active_primary_shards" : 3, "active_shards" : 6, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 }, "filebeat-6.5.1-2019.06.12" : { "status" : "green", "number_of_shards" : 3, "number_of_replicas" : 1, "active_primary_shards" : 3, "active_shards" : 6, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 }, "filebeat-6.5.1-2019.06.13" : { "status" : "green", "number_of_shards" : 3, 
all shards of health
 $ curl -XGET 'localhost:9200/_cluster/health?level=shards&pretty' | head -50 { "cluster_name" : "rdu-es-01", "status" : "green", "timed_out" : false, "number_of_nodes" : 9, "number_of_data_nodes" : 6, "active_primary_shards" : 1106, "active_shards" : 2213, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0, "indices" : { "filebeat-6.5.1-2019.06.10" : { "status" : "green", "number_of_shards" : 3, "number_of_replicas" : 1, "active_primary_shards" : 3, "active_shards" : 6, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "shards" : { "0" : { "status" : "green", "primary_active" : true, "active_shards" : 2, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 }, "1" : { "status" : "green", "primary_active" : true, "active_shards" : 2, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 }, "2" : { "status" : "green", "primary_active" : true, "active_shards" : 2, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 

The API also has many wait_* parameters, in which it will wait for various state changes before returning immediately or after a certain timeout .

0
source

Kibana => DevTools => Console:

 GET /_cluster/health 

enter image description here enter image description here

0
source

Source: https://habr.com/ru/post/979289/


All Articles