Is it possible to configure the same logstash.conf for different purposes? For example:
- application log
- stacktrace of errors
I have a Spring Boot application and I use logstash-logback-encoder plugin
Is it possible to configure the same logstash.conf for different purposes? For example:
I have a Spring Boot application and I use logstash-logback-encoder plugin
Yes you can but each index needs some kind of identification like for example type or tag. I prefer using tags because you might encounter a problem when your data has field called 'type'. Take a look at the example config file below for two indexes:
input {
file {
path => "/log/app_log.log"
tags => ["app_log"]
}
file {
path => "/log/stacktrace.log"
type => ["stacktrace"]
}
}
filter {
if "app_log" in [tags] {
#Some fitlering for app_log
}
if "stacktrace" in [tags] {
#Some fitlering for stacktrace
}
}
output {
if "app_log" in [tags] {
elasticsearch {
index => "app_log-%{+YYYY.MM.dd}"
hosts => ["localhost:9200"]
}
}
if "stacktrace" in [tags] {
elasticsearch {
index => "stacktrace-%{+YYYY.MM.dd}"
hosts => ["localhost:9200"]
}
}
}
You can also add as many jdbc inputs as you want. You don't have to worry about a break time between different inputs because logstash runs every input in parallel.