we have 2 environment one dev & one prod storing logs in dev path & prod path so how can i have 2 separate index for both of these based on path
input {
stdin{
type => "stdin-type"
}
file{
type => "json"
path => [ "/var/files/prod/*.log","/var/files/prod/**/*.log" ]
start_position => "beginning"
tags => "prod"
} file{
type => "json"
path => [ "/var/files/dev/*.log","/var/files/dev/**/*.log" ]
start_position => "beginning"
tags => "dev"
} }
filter {
grok {
match => {
"message" => [ "%{JSON:payload_raw}" ]
}
pattern_definitions => {
"JSON" => "{.*$"
} }
json {
source => "payload_raw"
target => "payload"
} mutate {
remove_field => [ "payload_raw","message" ]
} date {
match => [ "[payload][datetime]", "yyyy-MM-dd HH:mm:ss,SSS" ]
target => "@timestamp"
}}
output {
stdout {
codec => rubydebug }
if tags == "prod"
{ elasticsearch {
hosts => "localhost:9200"
index => "prod-logs" } }
if tags == "dev"
{
elasticsearch {
hosts => "localhost:9200"
index => "dev-logs" } }}