I guess I really did not need a sample of your json file as a generic response will be more useful to others.
You should be able to do something based on the sample config below to make it work (note I have not tested this exact config):
input {...}
filter {
json {
source => "message"
target => "parsedjson"
}
mutate {
add_field => {"somefield" => "%{[parsedjson][fieldkey]}}"}
}
}
output {
if [somefield] == "X" {
elasticsearch {
hosts => ["es-host"]
index => "logs-X-%{+YYYY.MM.dd}"
}
}
else if [somefield] == "Y" {
elasticsearch {
hosts => ["es-host"]
index => "logs-Y-%{+YYYY.MM.dd}"
}
}
else {
elasticsearch {
hosts => ["es-host"]
index => "logs-%{+YYYY.MM.dd}"
}
}
}