Loading...

Recipes for the Elasticsearch Admin

General

Check cluster health

GET _cluster/health

List all indices based on their health

GET _cat/indices?v&s=health:desc

Cluster Settings

Check cluster settings

GET _cluster/settings

Shard Allocation

Set to none or all.

PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": "all"
  }
}

Shard Allocation Filtering

Exclude node by IP address

PUT _cluster/settings
{
  "transient" : {
    "cluster.routing.allocation.exclude._ip" : "10.0.0.1"
  }
}

Disable allocation

PUT _cluster/settings
{
  "transient" : {
    "cluster.routing.allocation.exclude._ip" : null
  }
}

Hot Warm Allocation

Use _all for all indices.

PUT ha-logs-2017.12.*/_settings
{
  "settings": {
    "index.routing.allocation.require.box_type": "hot"
  }
}

Reindex API

POST /_reindex?pretty
{
  "source": {
    "remote": {
      "host": "http://localhost:9200",
      "username": "la_cebra",
      "password": "limitless"
    },
    "index": "ha-itu-2018.01.15"
  },
  "dest": {
    "index": "ha-itu-2018.01.15"
  }
}

License Management

GET /_xpack/license

Watcher

POST _xpack/watcher/_restart

Delete By Query

POST metrics-2018.01.16/_delete_by_query
{
  "query": {
    "bool": {
      "must": [
        {
          "exists": {
            "field": "environment"
          }
        }
      ],
      "must_not": [
        {
          "term": {
            "environment": {
              "value": "prd"
            }
          }
        },
        {
          "term": {
            "application": {
              "value": "nsb"
            }
          }
        }
      ]
    }
  }
}