Rolling over an index
When using a system that manages logs, it is very common to use rolling files for your log entries. By using this idea, we can have indices that are similar to rolling files.
We can define some conditions to be checked and leave it to Elasticsearch to roll new indices automatically and refer the use of an alias just to avirtualindex.
Getting ready
You need an up-and-running Elasticsearch installation, as we described in Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
To execute these commands, HTTP clients can be used, such as curl (https://curl.haxx.se/), postman (https://www.getpostman.com/), or others. I suggest using the Kibana console as it provides code completion and better character escaping for Elasticsearch.
How to do it…
To enable a rolling index, we need an index with an alias that points to it alone. For example, to set a log rolling index, we would follow these steps:
- We need an index with a
logs_write
alias that points to it alone...