Hello Team,
I am trying to implement the ILM Policy but I ran into an issue because my index name is dynamically created through logstash. Let me give you an explain of my setup and wat I am trying to do
-
I create the template using the below API
PUT _template/my_template
{
"index_patterns": ["logs*"],
"settings": {
"number_of_shards": 2,
"number_of_replicas": 0,
"index.lifecycle.name": "logs_policy",
"index.lifecycle.rollover_alias": "logs"}
} -
Then I created the index
PUT logs-000001
{
"aliases": {
"logs": {
"is_write_index" : true
}
}
} -
In my logstash setting I setup the below ilm policy settings
output {
elasticsearch {
ilm_rollover_alias => "logs"
ilm_pattern => "000001"
ilm_policy => "logs_policy"
}
}
All the above worked but now I want to create logs for each module so the logs that I am trying to send have a column module_name. So in logstash I can setup index name dynamically and it will create logs_%{module_name} but if I do that I will have to setup ilm policy and templates for each of the modules right ?? Is there a better way to implement it?
New logstash for Dynamic index
filter {
json {
source => "message"
remove_field => ["message", "@version"]
}
mutate{
lowercase => ["module_name"]
}
}
output {
elasticsearch {
index => "logs_%{module_name}"
}}