# Getting Problem with Logstash to Index Mysql Data

**URL:** <https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409>\
**Category:** Logstash\
**Created:** [April 25, 2018, 5:49am UTC](https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409 "2018-04-25T05:49:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nandan\_bigdata](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nandan\_bigdata](https://discuss.elastic.co/u/nandan_bigdata)\
**Post date:** [April 25, 2018, 5:49am UTC](https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409/1 "2018-04-25T05:49:43Z")

</div>

## Hi All, Details are as below. I am using Ubuntu 17.10 and installed Elastic Seach , Kibana,Logstash [Latest version 6+]. All 3 services are running perfectly.

## In my project , For Testing I am trying to Input Mysql table data to Elasticserseach By Using Logstash.

Below is my conf file.

> input {  
> jdbc {  
> jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/employees"  
> jdbc\_user =\> "root"  
> jdbc\_password =\> "nandan"  
> jdbc\_driver\_library =\> "/usr/share/logstash/mysql-connector-java-5.1.46.jar"  
> jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
> statement =\> "select \* from employees"  
> }  
> }  
> output {  
> elasticsearch {  
> index =\> "office"  
> document\_type =\> "emp"  
> document\_id =\> "%{ID}"  
> hosts =\> "localhost"  
> }  
> }

**Conf file location**  
Filename is db.conf and keep it in location as /usr/share/logstash  
and mysql-connector-java-5.1.46.jar file is also in the location of /usr/share/logstash/mysql-connector-java-5.1.46.jar

**Executing and getting below error**

 ![Logstash](https://us1.discourse-cdn.com/elastic/original/3X/6/7/6757301c39dd685e1a7d9fec5463bc84247fd553.PNG)

PLease let me know , how to resolve this issue.  
Thanks

---

<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:** [April 25, 2018, 6:00am UTC](https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409/2 "2018-04-25T06:00:44Z")

</div>

It looks like you've been following outdated documentation. Remove the "agent" argument. When in doubt look at the Logstash documentation for your version of Logstash.

---

<div class="post-metadata">

**Author:** ![nandan\_bigdata](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nandan\_bigdata](https://discuss.elastic.co/u/nandan_bigdata)\
**Post date:** [April 25, 2018, 9:22am UTC](https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409/3 "2018-04-25T09:22:12Z")

</div>

Thanks.. I got it and now resolve other issue and Got data indexed into Elastic search.

But currently this will be like Offline Data where I have to run my Logstash file again and again.  
I want to make sure when ever data will insert into Mysql, at same time data should be index into Elasticsearch, how can i achieve this ?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [April 25, 2018, 9:42am UTC](https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409/4 "2018-04-25T09:42:28Z")

</div>

Have a look at [scheduling](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_scheduling_2) and [state](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_state). It won't be inserted "at the same time", but with minimal delay.

---

<div class="post-metadata">

**Author:** ![nandan\_bigdata](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nandan\_bigdata](https://discuss.elastic.co/u/nandan_bigdata)\
**Post date:** [April 25, 2018, 2:29pm UTC](https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409/5 "2018-04-25T14:29:29Z")

</div>

Hi Jenni,  
In case of scheduling, I can't able to achieve real time indexing and second thing is in case of scheduling , I have to run my logstash conf life in cron mode like after every few seconds.  
In case Low data write this will work kind of good but scheduling will be not a good choice for REAL TIME APPLICATION.  
Thanks for your reply, by this I got more information.

---

<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:** [April 25, 2018, 3:33pm UTC](https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409/6 "2018-04-25T15:33:49Z")

</div>

> In case of scheduling, I can't able to achieve real time indexing and second thing is in case of scheduling , I have to run my logstash conf life in cron mode like after every few seconds.

The jdbc input has a built-in `schedule` option.

> In case Low data write this will work kind of good but scheduling will be not a good choice for REAL TIME APPLICATION.

Then you'll have to look into if you can use a MySQL trigger to ping Logstash when there's a change in the table. I don't know enough about MySQL triggers to give any advice.

---

<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 23, 2018, 3:33pm UTC](https://discuss.elastic.co/t/getting-problem-with-logstash-to-index-mysql-data/129409/7 "2018-05-23T15:33:53Z")

</div>

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