Distinguish json pattern and send it to specific index

hi everyone

I have a logstash container querying data from a mysql table called events. The mysql table contains a json field that can contain different data structures, i need to identify when an event contains certain structure and send the event to the corresponding index so that every index contains all the events that follow the same json structure.

Im using the jdbc input plugin to read data from mysql and the elasticsearch output plugin to index the events.

here is an example of the different json structures you can find in the json field of the events table (i know all the different structures that can happen)




I have tried some filters but i couldn't find any suitable solution for this

help me :frowning:

Perhaps something like

    if [data][0][message] {
        mutate { add_field => { "targetIndex" => "foo" } }
    } else if [data][0][value] {
        mutate { add_field => { "targetIndex" => "bar" } }
    } else {
        mutate { add_field => { "targetIndex" => "baz" } }
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.