Elastic Search

Elasticsearch Reset Features

“When working with Elasticsearch, you may encounter an instance where you need to reset your cluster and return to a new installation state.”

This tutorial will teach you how to reset your cluster using the Reset features API. Remember that resetting the cluster will remove all the state information stored in the system indices.

CAUTION: The instructions in this guide will lead to the absolute destruction of the data in your cluster. Do not use this API on a production server. Ensure to back up your cluster before making any changes. We do not hold any responsibility for any data loss that may result from the instructions in this guide.

Elasticsearch Get Available Feature States

You can view the available feature states in your cluster using the _features API. For example, the request is as shown:

curl -XGET "http://localhost:9200/_features" -H "kbn-xsrf: reporting"

The API responds with the list of available feature sets and their description. An example output is as shown:

{
  "features": [
    {
      "name": "async_search",
      "description": "Manages results of async searches"
    },
    {
      "name": "fleet",
      "description": "Manages configuration for Fleet"
    },
    {
      "name": "enrich",
      "description": "Manages data related to Enrich policies"
    },
    {
      "name": "searchable_snapshots",
      "description": "Manages caches and configuration for searchable snapshots"
    },
    {
      "name": "tasks",
      "description": "Manages task results"
    },
    {
      "name": "machine_learning",
      "description": "Provides anomaly detection and forecasting functionality"
    },
    {
      "name": "transform",
      "description": "Manages configuration and state for transforms"
    },
    {
      "name": "watcher",
      "description": "Manages Watch definitions and state"
    },
    {
      "name": "kibana",
      "description": "Manages Kibana configuration and reports"
    },
    {
      "name": "security",
      "description": "Manages configuration for Security features, such as users and roles"
    },
    {
      "name": "logstash_management",
      "description": "Enables Logstash Central Management pipeline storage"
    },
    {
      "name": "geoip",
      "description": "Manages data related to GeoIP database downloader"
    }
  ]
}

Elasticsearch Reset Feature States

We can use the reset features API to clear all the state information stored in the system indices by Elasticsearch features.

We can run a query as:

POST /_features/_reset

The API should return the operation and the state.

{
    "features": [
      {
        "feature_name": "async_search",
        "status": "SUCCESS"
      },
      {
        "feature_name": "enrich",
        "status": "SUCCESS"
      },
      {
        "feature_name": "fleet",
        "status": "SUCCESS"
      },
      {
        "feature_name": "geoip",
        "status": "SUCCESS"
      },
      {
        "feature_name": "kibana",
        "status": "SUCCESS"
      },
      {
        "feature_name": "logstash_management",
        "status": "SUCCESS"
      },
      {
        "feature_name": "machine_learning",
        "status": "SUCCESS"
      },
      {
        "feature_name": "searchable_snapshots",
        "status": "SUCCESS"
      },
      {
        "feature_name": "security",
        "status": "SUCCESS"
      },
      {
        "feature_name": "tasks",
        "status": "SUCCESS"
      },
      {
        "feature_name": "transform",
        "status": "SUCCESS"
      },
      {
        "feature_name": "watcher",
        "status": "SUCCESS"
      }
    ]
  }

NOTE: The reset API will reset all the feature states, including built-in and those provided by plugins in the master node.

We strongly PROHIBIT using this API in a production environment. It is only built for development and testing purposes.

Conclusion

This article explores how to use the Elasticsearch reset API to reset a cluster to the default state.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list