Logstash multiple inputs multiple outputs : <p>I'm trying to sync data between MySQL and Elasticsearch with Logstash. </p>

<p>I set multiple jdbc inputs and multiple outputs to different elasticsearch indexes ... and something I am doing wrong because everything is going to the else block.</p>

<p>Here is my config:</p>

<pre><code> input {
    jdbc {
        jdbc_connection_string =&gt; "jdbc:mysql:127.0.0.1:3306/whatever"
        jdbc_user =&gt; "xxx"
        jdbc_password =&gt; "yyy"
        jdbc_driver_library =&gt; "mysql-connector-java-5.1.41.jar"
        jdbc_driver_class =&gt; "com.mysql.jdbc.Driver"
        schedule =&gt; "* * * * *"
        statement =&gt; "SELECT * from table1 WHERE updated_at &gt; :sql_last_value order by updated_at"
        use_column_value =&gt; true
        tracking_column =&gt; updated_at
        type =&gt; "table1"
        last_run_metadata_path =&gt; "/opt/logstash-5.4.0/sql-last-values/table1"
    }
      jdbc {
        jdbc_connection_string =&gt; "jdbc:mysql:127.0.0.1:3306/whatever"
        jdbc_user =&gt; "xxx"
        jdbc_password =&gt; "yyy"
        jdbc_driver_library =&gt; "mysql-connector-java-5.1.41.jar"
        jdbc_driver_class =&gt; "com.mysql.jdbc.Driver"
        schedule =&gt; "* * * * *"
        statement =&gt; "SELECT * from table2 WHERE updated_at &gt; :sql_last_value order by updated_at"
        use_column_value =&gt; true
        tracking_column =&gt; updated_at
        type =&gt; "table2"
        last_run_metadata_path =&gt; "/opt/logstash-5.4.0/sql-last-values/table2"
    }
}
output {
    if [type] == "table1" {
           elasticsearch {
                hosts =&gt; ["localhost:9200"]
                index =&gt; "table1"
                document_type =&gt; "table1"
                document_id =&gt; "%{id}"
        }
        file {
                codec =&gt; json_lines
                path =&gt; "/opt/logstash-5.4.0/logs/table1.log"
        }

    } else if [type] == "table2" {
           elasticsearch {
                hosts =&gt; ["localhost:9200"]
                index =&gt; "table2"
                document_type =&gt; "table2"
                document_id =&gt; "%{id}"
        }
    } else {
         file {
                codec =&gt; json_lines
                path =&gt; "/opt/logstash-5.4.0/logs/unknown.log"
            }

    }
}
</code></pre>

<p>What am I doing wrong ? everything is going to the else block, to the /opt/logstash-5.4.0/logs/unknown.log</p>

<p>Is wrong my approach ? Should I have multiple files ?</p>

<p>thank you in advance</p>
