Elasticsearch Index aliases

Elasticsearch allows the user to create an alias to the indices.

For example, if we are maintaining a different range of employee details in different indices. And we want to query the employee details of all ranges from our application. We can create an alias for our existing indices.

So that we can query all the needed indices with a single endpoint. If we are frequently adding new indices to our data sources. we don’t need to update every time in the application configuration part if we are using alias concept.

Whenever we are adding new indices to our data source, we can simply add the new index to alias. The endpoint will remain the same, we add our additional index without affecting our application (let’s say we are pointing our website to Elasticsearch for data set).

Index 1: sales-people

Index2: research-people

Index 3: management-people

Alias: our-employees (Sales people, Research people, Management people)

In this case, if we want to query the Index 1 to Index 3, we can simply run our query by pointing to the “our-employees” alias.

Following some snippets of Elasticsearch alias actions

Adding Alias

POST /_aliases
{
   "actions": [
      {
         "add": {
            "index": "sales-people",
            "alias": "our-employees"
         }
      }
   ]
}

Removing Alias

POST /_aliases
{
   "actions": [
      {
         "remove": {
            "index": "sales-people",
            "alias": "our-employees"
         }
      }
   ]
}

Adding and Removing index in alias using the same call

POST /_aliases
{
   "actions": [
      {
         "remove": {
            "index": "sales-people",
            "alias": "our-employees"
         },
         "add": {
            "index": "research-people",
            "alias": "our-employees"
         }
      }
   ]
}

Happy exploring data 🙂

Steps to install Marvel in Elasticsearch

Marvel 1.3

Marvel is installed as an Elasticsearch plugin. The plugin must be installed on every node in the cluster. By default, the plugin will store data in the same Elasticsearch cluster that it is monitoring.

System requirements

Elasticsearch

Marvel 1.3 is compatible of Elasticsearch 1.0-1.7

Browser

The latest version of Chrome, Firefox or Safari is recommended. Internet Explorer 10 and above are also supported.

CORS

If you are using Sense to access a remote cluster, you will need to configure the cluster to allow CORS requests. See CORS for more details.

To install

We have to install Marvel on all nodes in the cluster to collect data, and the collected data will be stored in the same cluster.

Step 1:

Traverse to Elasticsearch home directory and run following command

bin/plugin -i elasticsearch/marvel/latest

Step 2:

Restart the Elasticsearch node.

Once the plugin is installed in all nodes, we can access the Marvel using the following URL

http://node-name:9200/_plugin/marvel/

node-name can be  Elasticsearch node name or IP address.

 

Marvel 2.0+

To use Marvel 2.0, we need to install two components:

  • An Elasticsearch plugin that collects data from each node in our cluster which will be installed on every node.
  • A Kibana app that provides the Marvel monitoring UI.

Step 1:

Install Marvel into Elasticsearch,

bin/plugin install license
bin/plugin install marvel-agent

By default, the Marvel plugin stores data in the same Elasticsearch cluster where it is installed.

Step 2:

Install Marvel into Kibana

bin/kibana plugin –install elasticsearch/marvel/latest

Step 3:

Start Elasticsearch and Kibana

bin/elasticsearch
bin/kibana

Step 4:

Visit the following URL with any modern browsers,

http://node-name:5601/app/marvel

 

Happy exploring data 🙂