You can point one alias to multiple indices like this:
POST /_aliases
{
"actions" : [
{ "add" : { "indices" : ["l1", "l2"], "alias" : "A1" } }
]
}
or even point the alias to a wildcard index pattern like this:
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "l*", "alias" : "A1" } }
]
}
EDIT: With rollover, you can only point the alias to one index - the latest index. If you want an alias that points to the last 2 indices, n indices, or all of the indices matching the pattern l*
, you'll have to create an additional alias using the requests I showed above.
EDIT 2: If I wanted to maintain 30 days of logs in an index, this is how I would accomplish it. I stayed consistent with the naming of indices as 'l1' and alias of 'A1'. After the first 30 days, a new index will be created called l000002 (the naming convention is incrementing the number of the last index and zero padding with a length of 6) and the alias A1
will be pointing at the index l000002. I would create a second alias to refer to 'l*' like you originally desired.
PUT /l1
{ "aliases": { "A1": {} } }
POST /A1/_rollover
{ "conditions": { "max_age": "30d" } }
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "l*", "alias" : "A2" } }
]
}