Loading...

Create alias for indices in Elasticsearch

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

If you have multiple indices and build your visualisations and dashboard in Kibana, you might consider using an alias. The advantage is that the physical index name can always be removed, renamed, reindex. The alias gives you the flexibility that your Kibana objects remain consistent, but in the background you have to freedom to reorganise. This post illustrates two examples.

The first example is an environment case. In your development you have dev, a test system, a staging system and a production. Following curl command with JSON data, creates an alias dev for the indices fo-dev-*. The wildcard can be used.

curl -XPOST 'http://localhost:9200/_aliases' -d '
{
    "actions" : [
        { "add" : { "index" : "fo-dev-*", "alias" : "dev" } }
    ]
}'
{"acknowledged":true}

The second case is the alias stats for the indices metrics-*.

curl -XPOST 'http://localhost:9200/_aliases' -d '
{
    "actions" : [
        { "add" : { "index" : "metrics-*", "alias" : "stats" } }
    ]
}'
{"acknowledged":true}
Please remember the terms for blog comments.