How do I create an alias across two indices using logstash?
The cluster I'm working on has two main indexes, say indexA
and indexB
, but these two indexes are indexed every day, so ok, I have indexA-{+YYYY.MM.dd}
and indexB-{+YYYY.MM.dd}
.
I want to have one alias that collects indexA-{+YYYY.MM.dd}
both indexB-{+YYYY.MM.dd}
together and called alias-{+YYYY.MM.dd}
.
Does anyone know how to collect two indexes in one alias using logstash?
Thank you in advance
source to share
As far as I know, there is no way to do this using logstash directly. You can do this from an external program using the elasticsearch API: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
For example:
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{ "add" : { "index" : "indexA-2015.01.01", "alias" : "alias-2015.01.01" } },
{ "add" : { "index" : "indexB-2015.01.01", "alias" : "alias-2015.01.01" } }
]
}'
Another option (which doesn't suit your requirements for having a named name alias-yyyy.mm.dd
) is to use an index template that automatically adds an alias when the index is created.
See http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html :
curl -XPUT localhost:9200/_template/add_alias_template -d '{
"template" : "index*",
"aliases" : {
"alias" : {}
}
}
}'
This will add an alias alias
to each index named index
*.
Then you can fulfill all your requests with an alias. You can set up this alias in Kibana as an index and everything will work as expected.
source to share