Every tutorial or manual out there talks about integrating Filebeat with ILM rollover. We're not using Filebeat (it doesn't really make sense to send logs through actual files when we could do that without involving filesystem by going this route: docker container -> logspout -> logstash -> elastic
).
In Logstash, we're determining what kind of index the document/log event belongs to (there are app logs, access-logs and unsorted logs; the idea being that we want to retain app logs for the longest, access-logs for as much as can be fit in 20gb and unsorted can only enjoy 4gb of space). I suppose in Logstash I can use the index alias directly, so I've defined index alias for access logs with the name access-logs
in the Index Template by:
- Creating a lifecycle that manages 20gb rollover, called
access-logs
- Adding
"index": { "lifecycle": { "name": "access-logs", "rollover_alias": "access-logs" }
in the settings of Index Template
This didn't seem to work. When I ran GET /_alias
to get all defined aliases, although I could see access-logs
, it differed from other aliases like apm-7.7.0-span
one for example, the latter one looked like this:
"apm-7.7.0-span-000001" : {
"aliases" : {
"apm-7.7.0-span" : {
"is_write_index" : true
}
}
}
Mine looked like this:
"app-000001" : {
"aliases" : {
"app" : { }
}
}
I then tried adding
{
"access-logs": { "is_write_index": true }
}
to the Index Template in Aliases section. This seemed to do the job but on the next day I saw an error saying that the alias points to two indexes at the same time (both indexes are actually the same index as well).
illegal_argument_exception: Rollover alias [access-logs] can point to multiple indices, found duplicated alias [[access-logs]] in index template [access-logs]
I suppose what I did basically configured the alias twice.
So what's the correct way to configure ILM in Kibana for indexes without any involvement of Filebeats? While letting Logstash use a single index name (an alias) to send documents to.
Update: I've removed the {"access-logs": {"is_write_index": true } }
from Aliases section and ILM policy from Settings in the Index Template, then in the ILM I assigned the lifecycle to that index template (ie using GUI instead of writing JSON settings manually), then deleted the index itself so that it's recreated with new configuration. In order to test that it will actually do a rollover I've set ILM hot phase threshold to 100mb, after doing that I've started getting this error message:
illegal_argument_exception: index.lifecycle.rollover_alias [access-logs] does not point to index [access-logs-000001]
I tried to kill that index again so that it's recreated, the error still remains. GET /_alias
says:
"access-logs-000001" : {
"aliases" : { }
},
I don't understand what's happening.