Multiple JDBC input for different tables and output into separate indexes

Hello I'm new to ELK. Question -
How do I use different index when importing tables from DB using logstash. I have used multiple JDBC input for different tables and separate output for each table in logstash. Logstash shows correct last timestamp for each table/input, but Kibana/Elasticsearch display all combined data for all tables.

Code is like this:
input {
jdbc {
table1
}

jdbc {
table2
}

filter {
mutate {table1_col}
mutate {table2_col}
}

output {
elasticsearch {
index => "table1"
}

elasticsearch {
index => "table2"
}
}

Welcome to the community.

You can add type or tags in input and based on that, add IFs.

input {
  jdbc {
   table1
   type=>"table1"
  }

  jdbc {
   table2
   type=>"table2"
  }
}
output {
if [type]=="table1"{
  elasticsearch {
   index => "table1"
  }
 }
 if [type]=="table2"{
  elasticsearch {
    index => "table2"
  }
 }
}
1 Like

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