Description :

Voici un script pour des opérations courantes basiques sur les indexes ES, telle que le delete, open, close et list.

Script : es-operations.sh

Help

./es-operations.sh -h

Description : Script to Elasticsearch operations.

Usage : es-operations.sh [-h] [-l] [-S] [-D] -H <host> -P <port> -p <proxypass path> -c <command operation> -i <index>

   -h : Help
   -D : Debug script
   -S : Web Server is HTTPS
   -H : Elasticsearch host - mandatory
   -P : Elasticsearch port - mandatory
   -p : Web Server proxypass if is set (set -P to listen port of Web Server) - mandatory
   -c : Command :
        - delete
        - open
        - close
        - list

   -i : index

Note : il est possible de faire une requête en HTTP/HTTPS, au travers d’un Apache/NGINX en mode reverse proxy.

Exemples

Liste des indexes

En direct

./es-operations.sh -H 127.0.0.1 -P 9200 -c list
#####=> Result to list
health index               pri rep docs.count docs.deleted store.size pri.store.size 
green  logstash-2015.07.30   5   0         86            0    292.4kb        292.4kb 
green  logstash-2014.09.28   5   0        376            0    407.7kb        407.7kb 
green  kibana-int            5   0          3            0     43.3kb         43.3kb 
green  nodes_stats           1   0         42            0    648.4kb        648.4kb 
yellow logstash-2014.10.22   5   1         17            0     40.1kb         40.1kb 
green  logstash-2014.10.18   5   0          7            0     36.3kb         36.3kb 
yellow logstash-2016.04.27   5   1         32            0    151.6kb        151.6kb 
green  logstash-2014.09.08   5   0        114            0      242kb          242kb 
yellow logstash-2016.04.28   5   1         45            0    245.2kb        245.2kb

Via un reverse proxy

./es-operations.sh -H 192.168.5.40 -P 80 -p /my_elasticsearch -c list
#####=> Result to list
health index               pri rep docs.count docs.deleted store.size pri.store.size 
green  logstash-2015.07.30   5   0         86            0    292.4kb        292.4kb 
green  logstash-2014.09.28   5   0        376            0    407.7kb        407.7kb 
green  kibana-int            5   0          3            0     43.3kb         43.3kb 
green  nodes_stats           1   0         44            0    719.2kb        719.2kb 
yellow logstash-2014.10.22   5   1         17            0     40.1kb         40.1kb 
green  logstash-2014.10.18   5   0          7            0     36.3kb         36.3kb 
yellow logstash-2016.04.27   5   1         32            0    151.6kb        151.6kb 
green  logstash-2014.09.08   5   0        114            0      242kb          242kb 
yellow logstash-2016.04.28   5   1         48            0    274.7kb        274.7kb

Fermer un index

./es-operations.sh  -H 127.0.0.1 -P 9200 -c close -i logstash-2014.10.22
#####=> Result to close
{"acknowledged":true}

Fermer X index

./es-operations.sh  -H 127.0.0.1 -P 9200 -c close -i logstash-2014.10.*
#####=> Result to close
{"acknowledged":true}

Ouverture d’un index

./es-operations.sh  -H 127.0.0.1 -P 9200 -c open -i logstash-2014.10.22
#####=> Result to open
{"acknowledged":true}

Suppression d’un index

./es-operations.sh  -H 127.0.0.1 -P 9200 -c delete -i logstash-2014.10.22
#####=> Result to delete
{"acknowledged":true}

Source :