据我所知,没有办法直接用logstash做到这一点。您可以使用Elasticsearch API从外部程序执行此操作:http ://www.elastic.co/guide/en/elasticsearch/reference/current/indices- aliases.html
例如:
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" } }
]
}'
另一个选项(不满足您将其命名为的要求alias-yyyy.mm.dd
)是使用创建索引时自动添加别名的索引模板。
参见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" : {}
}
}
}'
这将为alias
每个名为index
*的索引添加别名。
然后,您可以针对别名进行所有查询。您可以在Kibana中将该别名设置为索引,然后一切正常。