Skip to content

Instantly share code, notes, and snippets.

@fdv
Last active February 2, 2021 14:44
Show Gist options
  • Save fdv/c1c37c3102fb2c33de67 to your computer and use it in GitHub Desktop.
Save fdv/c1c37c3102fb2c33de67 to your computer and use it in GitHub Desktop.
An ElasticSearch management cheat sheet

These are the snippets I use most of the time when administrating my ES cluster

To be updated

Settings to change before you do something

Before restarting a data node

curl -XPUT 'http://escluster:9200/_cluster/settings' -d '{
    "transient" : {
        "cluster.routing.allocation.enable": "none"
    }
}'

After the node has joined

curl -XPUT 'http://escluster:9200/_cluster/settings' -d '{
    "transient" : {
        "cluster.routing.allocation.enable": "all"
    }
}'

Before a major restart (remember this will disappear if you restart all the master nodes at once)

curl -XPUT 'http://escluster:9200/_cluster/settings' -d '{
    "transient" : {
        "cluster.routing.allocation.cluster_concurrent_rebalance": 20,
        "indices.recovery.concurrent_streams": 20,
        "cluster.routing.allocation.node_initial_primaries_recoveries": 20,
        "cluster.routing.allocation.node_concurrent_recoveries": 20,
        "indices.recovery.max_bytes_per_sec": "2048mb",
        "cluster.routing.allocation.disk.threshold_enabled" : true,
        "cluster.routing.allocation.disk.watermark.low" : "90%",
        "cluster.routing.allocation.disk.watermark.high" : "98%"
    }
}'

Before a huge bulk insert

curl -XPUT 'escluster:9200/_settings' -d '
{
    "index" : {
        "number_of_replicas" : 0,
        "refresh_interval" : "1m"
    }
}'

After a huge bulk insert

curl -XPUT 'escluster:9200/_settings' -d '
{
    "index" : {
        "number_of_replicas" : 1,
        "refresh_interval" : "1s"
    }
}'

Optimize an existing index

curl -XPOST 'http://escluster:9200/blackhole_2_201301/_optimize' -d '{
    "max_num_segments" : 1
}'

Enables location awareness

curl -XPUT 'http://escluster:9200/_cluster/settings' -d '{
    "transient" : {
        "cluster.routing.allocation.awareness.attributes": "rack_id"
    }
}'

Get useful information

Nodes information

curl -XGET https://escluster/_cat/nodes?v

Indices information

curl -XGET https://escluster/_cat/indices?v

Shard allocation information

curl -XGET https://escluster/_cat/shards?v

Recovery information

curl -XGET https://escluster/_recovery?pretty=true&active_only=true

Segments information (can be extremely verbose)

curl -XGET https://escluster/_segments?pretty

Cluster stats

curl -XGET https://escluster/_cluster/stats?pretty

Nodes stats

curl -XGET https://escluster/_nodes/stats?pretty

Indice stats

curl -XGET https://escluster/someindice/_stats?pretty

Indice mapping

curl -XGET https://escluster/someindice/_mapping

Cluster dynamic settings

curl -XGET https://escluster/_cluster/settings

All the cluster settings (can be extremely verbose)

curl -XGET https://escluster/_settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment