Hi
I have a Category field (cat) which can have following value and future expect to add more.
BL
LA
KA
Currently I have following code to output to the different Elasticsearch indices from our Logstash pipeline . I was wondering is there a dynamic way where I don't have to add a new if statement each time I have a new Category and If I can achieve the following with more dynamic and small code and should automatically output to the right index without me add a new statement each time I add a new category.
output {
if "BL" in [cat] {
elasticsearch {
hosts => "elasticsearch:9200"
index => "Index-BL"
}
if "LA" in [cat] {
elasticsearch {
hosts => "elasticsearch:9200"
index => "Index-LA"
}
if "KA" in [cat] {
elasticsearch {
hosts => "elasticsearch:9200"
index => "Index-KA"
}