# Can we have multiple input and output section in logstash config file

**URL:** <https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778>\
**Category:** Beats\
**Created:** [April 12, 2018, 9:18am UTC](https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778 "2018-04-12T09:18:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![manjur](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@manjur](https://discuss.elastic.co/u/manjur)\
**Post date:** [April 12, 2018, 9:18am UTC](https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778/1 "2018-04-12T09:18:52Z")

</div>

can we have multiple input and output section in logstash config file. So that we can deal with multiple indexes in same run.

---

<div class="post-metadata">

**Author:** ![adrisr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrisr/32/25423_2.png) [@adrisr](https://discuss.elastic.co/u/adrisr)\
**Post date:** [April 12, 2018, 12:03pm UTC](https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778/2 "2018-04-12T12:03:59Z")

</div>

Hi, can you be more explicit on what you want to achieve? Which is your beats setup and how do you want it to look like in Elasticsearch?

---

<div class="post-metadata">

**Author:** ![manjur](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@manjur](https://discuss.elastic.co/u/manjur)\
**Post date:** [April 12, 2018, 2:10pm UTC](https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778/3 "2018-04-12T14:10:43Z")

</div>

my logstash.config file looks like. i am transferring data from sqlserver to ES .

input {  
jdbc {  
jdbc\_driver\_library =\> "C:\Users\manjur.gani\Desktop\ElasticSearch\logstash-6.2.3\bin\mysql-connector-java-5.1.46-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/sys"  
jdbc\_user =\> "root"  
jdbc\_password =\> "ganiclub"  
statement =\> "SELECT \* from sys\_employee"  
schedule =\> "\* \* \* \* \*"  
}  
}  
filter{  
}  
output  
{  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "employee1"  
}

=\>what i want to achieve , i should able to give multiple jdbc connection and in output i need multiple indexes like

output  
{  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "employee1"  
Index=\>""emp2"  
index=\>"emp3"  
}

---

<div class="post-metadata">

**Author:** ![philippkahr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippkahr/32/100137_2.png) [@philippkahr](https://discuss.elastic.co/u/philippkahr)\
**Post date:** [April 12, 2018, 2:25pm UTC](https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778/4 "2018-04-12T14:25:21Z")

</div>

This can be achieved fairly easy.

You can have multiple inputs with the same "type" e.g. jdbc.  
just add those multiple times, is there a difference in the username you are using, or only the statement?

In the output box, you could do something like `if "root" in jdbc_user { output 1 }`  
if the username is always the same I would go for a tagging, this would add an extra field to each of your line but, it will help you with the output. For each input you would need to add `tags => "jdbc-1`afterwards you can do the same thing in the output with `if "jdbc-1" in [tags]`

---

<div class="post-metadata">

**Author:** ![manjur](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@manjur](https://discuss.elastic.co/u/manjur)\
**Post date:** [April 12, 2018, 2:50pm UTC](https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778/5 "2018-04-12T14:50:41Z")

</div>

hi philip,

i did it in the same way , but i don't want to give jdbc connection string each time, i have one jdbc connection and in the statement part ex:"select \* from emp", i need multiple statement as input for multiple indexes. Is there any way where i can do like below

input  
{  
jdbc {  
jdbc\_driver\_library =\> "C:\Users\manjur.gani\Desktop\ElasticSearch\logstash-6.2.3\bin\mysql-connector-java-5.1.46-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/sys"  
jdbc\_user =\> "root"  
jdbc\_password =\> "ganiclub"  
}

{  
statement=\>select \* from emp  
type=\>"emp"  
}

{  
statement=\>select \* from manager  
type=\>"mgr"  
}

}

---

<div class="post-metadata">

**Author:** ![philippkahr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippkahr/32/100137_2.png) [@philippkahr](https://discuss.elastic.co/u/philippkahr)\
**Post date:** [April 12, 2018, 4:18pm UTC](https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778/6 "2018-04-12T16:18:05Z")

</div>

[https://stackoverflow.com/questions/37613611/multiple-inputs-on-logstash-jdbc](https://stackoverflow.com/questions/37613611/multiple-inputs-on-logstash-jdbc) no it is not possible to do anything like that. When you open up a `jdbc` it expects all the fields like `jdbc_driver_library` to be filled. Please correct me if I am wrong.

---

<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:** [May 10, 2018, 6:18pm UTC](https://discuss.elastic.co/t/can-we-have-multiple-input-and-output-section-in-logstash-config-file/127778/7 "2018-05-10T18:18:15Z")

</div>

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