# Logstash jdbc input plugin multiple tables on elasticsearch output plugin

**URL:** <https://discuss.elastic.co/t/logstash-jdbc-input-plugin-multiple-tables-on-elasticsearch-output-plugin/84506>\
**Category:** Logstash\
**Created:** [May 4, 2017, 8:44am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-multiple-tables-on-elasticsearch-output-plugin/84506 "2017-05-04T08:44:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maurice\_Lionel\_Ndion](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Maurice\_Lionel\_Ndion](https://discuss.elastic.co/u/Maurice_Lionel_Ndion)\
**Post date:** [May 4, 2017, 8:44am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-multiple-tables-on-elasticsearch-output-plugin/84506/1 "2017-05-04T08:44:20Z")

</div>

Hello everyone,  
I am delighted to be part of this community .

I start with the elastic stack suite and i'm confronted with an issue

I use the plugin jdbc of logstash to access a mysql bd containing seven tables, I then put the request to each table in the files "accounts.conf"; "Connections.conf"; "Credits.conf"; "Customers.conf"; "Inboxs.conf"; "Outboxs.conf"; "Prefixs.conf"

The problem is that the connection type documents of the index connections are found in the accounts index with the type account

this is the content of accounts.conf

input {  
jdbc {  
jdbc\_driver\_library =\> "/usr/share/java/mysql-connector-java-5.1.17.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_connection\_string =\> "jdbc:mysql://my\_ip\_server:3306/my\_server"  
jdbc\_user =\> "my\_user"  
jdbc\_password =\> "my\_password"  
schedule =\> "\*/5 \* \* \* \*"  
use\_column\_value =\> true  
tracking\_column =\> account\_id  
statement =\> "SELECT AccID AS account\_id, AccName AS name, AccType AS type, AccStatus AS status, AccNote AS note, AccDisabled AS disabled FROM accounts"  
type =\> "account"  
}  
}

output {  
elasticsearch {  
hosts =\> "http://my\_elasticsearch:9200"  
user =\> "my\_user"  
password =\> "my\_password"  
index =\> "accounts"  
document\_type =\> "account"  
document\_id =\> "%{account\_id}"  
}  
}

this is the content of connections.conf

input {  
jdbc {  
jdbc\_driver\_library =\> "/usr/share/java/mysql-connector-java-5.1.17.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_connection\_string =\> "jdbc:mysql://my\_ip\_server:3306/my\_server"  
jdbc\_user =\> "my\_user"  
jdbc\_password =\> "my\_password"  
schedule =\> "\*/10 \* \* \* \*"  
use\_column\_value =\> true  
tracking\_column =\> connection\_id  
statement =\> "SELECT ConId AS connection\_id, CustId AS customer\_id, ConAccountid AS account\_id, ConPort AS port, ConAccountname AS account\_name, ConAccounttype AS account\_type FROM connection"  
type =\> "connection"  
}  
}

output {  
elasticsearch {  
hosts =\> "http://my\_elasticsearch:9200"  
user =\> "elastic"  
password =\> "changeme"  
index =\> "connections"  
document\_type =\> "connection"  
document\_id =\> "%{connection\_id}"  
}  
}

this is the content of credits.conf

input {  
jdbc {  
jdbc\_driver\_library =\> "/usr/share/java/mysql-connector-java-5.1.17.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_connection\_string =\> "jdbc:mysql://my\_ip\_server:3306/my\_server"  
jdbc\_user =\> "my\_user"  
jdbc\_password =\> "my\_password"  
schedule =\> "\*/15 \* \* \* \*"  
use\_column\_value =\> true  
tracking\_column =\> credit\_id  
statement =\> "SELECT AccID AS credit\_id, AccName AS name, AccBalance AS balance, AccReserved AS reserved, AccOverdraft AS overDraft, AccLowBalance AS lowBalance, AccTimeInterval AS timeInterval, AccContact AS contact, AccNote AS note, AccDisabled AS disabled FROM credits"  
type =\> "credit"  
}  
}

output {  
elasticsearch {  
hosts =\> "http://my\_elasticsearch:9200"  
user =\> "elastic"  
password =\> "changeme"  
index =\> "credits"  
document\_type =\> "credit"  
document\_id =\> "%{credit\_id}"  
}  
}

Thank you!

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [May 5, 2017, 5:22am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-multiple-tables-on-elasticsearch-output-plugin/84506/2 "2017-05-05T05:22:33Z")

</div>

Logstash has a single event pipeline. It doesn't care if you split your configuration into multiple files. The events from all inputs in all configuration files will reach all filters and all outputs unless you use conditionals. For example, if you say

```nohighlight
output {
  if [type] == "credit" {
    elasticsearch {
      hosts => "http://my_elasticsearch:9200"
      user => "elastic"
      password => "changeme"
      index => "credits"
      document_type => "credit"
      document_id => "%{credit_id}"
    }
  }
}

```

only credit events will reach the credits index.

---

<div class="post-metadata">

**Author:** ![Maurice\_Lionel\_Ndion](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Maurice\_Lionel\_Ndion](https://discuss.elastic.co/u/Maurice_Lionel_Ndion)\
**Post date:** [May 5, 2017, 9:43am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-multiple-tables-on-elasticsearch-output-plugin/84506/3 "2017-05-05T09:43:38Z")

</div>

Hello Magnus Bäck,

it's alright It works.

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 2, 2017, 9:47am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-multiple-tables-on-elasticsearch-output-plugin/84506/4 "2017-06-02T09:47:12Z")

</div>

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