Home > front end >  How to check if Elasticsearch is running using CURL?
How to check if Elasticsearch is running using CURL?

Time:03-24

I have downloaded the latest ElasticSearch & Kibana to my local machine (Ubuntu 20).

After extraction, I execute bin/elasticsearch & bin/kibana.

Execution successfully, I can open kibana running fine in my browser http://localhost:5601/

But from the CLI, using CURL command couldnot reach curl -XGET http://localhost:9200/`

In the document I have followed there is written a command to check if elasticsearch is up and running.

curl --cacert $ES_PATH_CONF/tls_auto_config_<timestamp>/http_ca.crt -u elastic https://localhost:9200

But I do not understand what is $ES_PATH_CONF/tls_auto_config_<timestamp>.

Can anybody please help me?

CodePudding user response:

My guess is that you have not installed any cert than you can simply use below command.

curl -u elastic https://localhost:9200

CodePudding user response:

I am assuming you have followed the below steps to install on Linux as per documentation.

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.1-linux-x86_64.tar.gz
tar -xzvf elasticsearch-8.0.1-linux-x86_64.tar.gz
cd elasticsearch-8.0.1
./bin/elasticsearch

According to this step you must be in elasticsearch-8.0.1.

/elasticsearch-8.0.1 - ES_HOME folder.
/elasticsearch-8.0.1/config - ES_PATH_CONF folder.
/elasticsearch-8.0.1/config/certs/http_ca.crt - HTTP CA Certificate.

When you start Elasticsearch for the first time, passwords are generated for the elastic user and TLS is automatically configured for you.

Open same path in another terminal window or tab.

So you need to pass the http_ca.crt path to the curl command like below.

curl --cacert config/certs/http_ca.crt -u "elastic:password" https://localhost:9200

Also You can set the environment variable.

export ES_HOME=/path-to-ES_HOME/elasticsearch-8.0.1
export ES_PATH_CONF=/path-to-ES_HOME/elasticsearch-8.0.1/config

You can use environment variable directly in curl

curl --cacert $ES_PATH_CONF/certs/http_ca.crt -u "elastic:password" https://localhost:9200

The password must have shown while installing the elasticsearch. If you have not noted, you can change with below command:

bin/elasticsearch-reset-password -u elastic

You can refer more here https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html#_check_that_elasticsearch_is_running

  • Related