Define Elasticsearch Indices and Aliases

1.5 hours
  • 7 Learning Objectives

About this Hands-on Lab

In Elasticsearch, the data we index is stored in an **index**. The word _index_ here is used as both a verb and a noun. Essentially, we perform an index operation in order to store data in an index. Before we can do this, however, we first need to understand the structure of an index and how to define one to meet specific requirements. In this hands-on lab, you will define Elasticsearch indexes by completing the following tasks:

* Configure the number of primary shards of an index
* Configure the number of replica shards of an index
* Allocate the shards for an index to **hot** nodes
* Allocate the shards for an index to **warm** nodes
* Associate indexes with aliases

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the logs-2020-01-05 index.

Use the Kibana console tool to execute the following:

PUT logs-2020-01-05
{
  "aliases": {
    "logs": {},
    "this_week": {}
  }, 
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1,
    "index.routing.allocation.require.temp": "warm"
  }
}
Create the logs-2020-01-06 index.

Use the Kibana console tool to execute the following:

PUT logs-2020-01-06
{
  "aliases": {
    "logs": {},
    "this_week": {}
  }, 
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1,
    "index.routing.allocation.require.temp": "warm"
  }
}
Create the logs-2020-01-07 index.

Use the Kibana console tool to execute the following:

PUT logs-2020-01-07
{
  "aliases": {
    "logs": {},
    "this_week": {}
  }, 
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1,
    "index.routing.allocation.require.temp": "warm"
  }
}
Create the logs-2020-01-08 index.

Use the Kibana console tool to execute the following:

PUT logs-2020-01-08
{
  "aliases": {
    "logs": {},
    "this_week": {}
  }, 
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1,
    "index.routing.allocation.require.temp": "warm"
  }
}
Create the logs-2020-01-09 index.

Use the Kibana console tool to execute the following:

PUT logs-2020-01-09
{
  "aliases": {
    "logs": {},
    "this_week": {}
  }, 
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1,
    "index.routing.allocation.require.temp": "warm"
  }
}
Create the logs-2020-01-10 index.

Use the Kibana console tool to execute the following:

PUT logs-2020-01-10
{
  "aliases": {
    "logs": {},
    "this_week": {},
    "yesterday": {}
  }, 
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1,
    "index.routing.allocation.require.temp": "hot"
  }
}
Create the logs-2020-01-11 index.

Use the Kibana console tool to execute the following:

PUT logs-2020-01-11
{
  "aliases": {
    "logs": {},
    "this_week": {},
    "today": {}
  }, 
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1,
    "index.routing.allocation.require.temp": "hot"
  }
}

Additional Resources

You work as a system administrator for a company that wants to use Elasticsearch with Kibana to store and analyze some log data. You are being asked to prepare the Elasticsearch cluster for the log data by creating some indexes. Logs are considered time-series data, and we typically care most about the most recent logs. We need to make sure the data we care most about is allocated to our fastest, or "hot," nodes. The data we care less about can be allocated to slower "warm" nodes, which won't be indexed or searched as often. We also need to be able to search the data using aliases such as "this_week", "yesterday", or "today". Aliases make it easy to search the data you care about because you don't have to know specific index names.

You have a pre-configured, 6-node Elasticsearch cluster with Kibana already set up and running on the coordinator-1 node. You will need to use Kibana's console tool to interact with Elasticsearch's APIs to create the following indexes:

-----------------+-----------+-----------+----------+------------
 Name            | Aliases   | Primaries | Replicas | Allocation 
-----------------+-----------+-----------+----------+------------
 logs-2020-01-05 | logs      | 2         | 1        | warm       
                 | this_week |           |          |            
-----------------+-----------+-----------+----------+------------
 logs-2020-01-06 | logs      | 2         | 1        | warm       
                 | this_week |           |          |            
-----------------+-----------+-----------+----------+------------
 logs-2020-01-07 | logs      | 2         | 1        | warm       
                 | this_week |           |          |            
-----------------+-----------+-----------+----------+------------
 logs-2020-01-08 | logs      | 2         | 1        | warm       
                 | this_week |           |          |            
-----------------+-----------+-----------+----------+------------
 logs-2020-01-09 | logs      | 2         | 1        | warm       
                 | this_week |           |          |            
-----------------+-----------+-----------+----------+------------
 logs-2020-01-10 | logs      | 2         | 1        | hot        
                 | this_week |           |          |            
                 | yesterday |           |          |            
-----------------+-----------+-----------+----------+------------
 logs-2020-01-11 | logs      | 2         | 1        | hot        
                 | this_week |           |          |            
                 | today     |           |          |            
-----------------+-----------+-----------+----------+------------

To use Kibana, navigate to the public IP address of the coordinator-1 node in your web browser and login with:

  • Username: elastic
  • Password: la_elastic_409

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?