# Error while sending data from mysql to Logstash

**URL:** <https://discuss.elastic.co/t/error-while-sending-data-from-mysql-to-logstash/154908>\
**Category:** Elasticsearch\
**Created:** [October 31, 2018, 6:17pm UTC](https://discuss.elastic.co/t/error-while-sending-data-from-mysql-to-logstash/154908 "2018-10-31T18:17:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![emma1](https://avatars.discourse-cdn.com/v4/letter/e/74df32/32.png) [@emma1](https://discuss.elastic.co/u/emma1)\
**Post date:** [October 31, 2018, 6:17pm UTC](https://discuss.elastic.co/t/error-while-sending-data-from-mysql-to-logstash/154908/1 "2018-10-31T18:17:38Z")

</div>

Hi All,

below is my config file for sending data from mysql to logstash

input {  
jdbc {  
jdbc\_driver\_library =\> "C:/ELK/logstash-6.2.3/mysql-connector-java-5.1.47/mysql-connector-java-5.1.47-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/automation?useSSL=true&verifyServerCertificate=false&requireSSL=true"  
jdbc\_user =\> ""  
jdbc\_password =\> ""  
statement =\> "select \* from `tbl_hybris_waiting` where ai\_id\>:sql\_last\_value"  
use\_column\_value =\> true  
tracking\_column =\> ai\_id  
tracking\_column\_type =\> "numeric"  
last\_run\_metadata\_path =\> "C:\ELK\data\MetarunData.logstash\_jdbc\_last\_run\_hybriswaiting\_database"  
#clean\_run =\> true   
schedule =\>"\* \* \* \* \* \*"  
}  
}

filter {  
mutate { convert =\> {"ai\_id" =\> "integer"} }  
date {  
match =\> ["execution month", "yyyy\MM"]  
target =\> "execution month"  
}

}  
output{  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "hybriswaiting\_database"  
}  
}

and table data is in below manner

| ai\_id | date | processcode | action | execution time | region | execution month |
| --- | --- | --- | --- | --- | --- | --- |
| 1 | 10/26/2018 15:39 | [sddhfgudh@gmail.com](mailto:sddhfgudh@gmail.com) | waitForStockNotification | Tue Oct 24 06:58:03 GMT 2017 | AU | 2017-10 |
| 2 | 10/26/2018 15:39 | [sddhfgudh@gmail.com](mailto:sddhfgudh@gmail.com) | waitForStockNotification | Mon Oct 23 02:38:18 GMT 2017 | AU | 2017-10 |
| 3 | 10/26/2018 15:39 | [sddhfgudh@gmail.com](mailto:sddhfgudh@gmail.com) | waitForStockNotification | Thu Oct 26 11:11:15 GMT 2017 | AU2 | 2017-10 |
| 4 | 10/26/2018 15:39 | [sddhfgudh@gmail.com](mailto:sddhfgudh@gmail.com) | waitForStockNotification | Sun Oct 29 05:35:24 GMT 2017 | AU2 | 2017-10 |

but im getting the below error while sending data to logstash

Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"hybriswaiting\_database", :\_type=\>"doc", :\_routing=\>nil}, #LogStash::Event:0x79d612f5], :response=\>{"index"=\>{"\_index"=\>"hybriswaiting\_database", "\_type"=\>"doc", "\_id"=\>"PPROy2YBBHN1pAdlFGMy", "status"=\>400, "error"=\>{"type"=\>"mapper\_parsing\_exception", "reason"=\>"failed to parse [execution month]", "caused\_by"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"Invalid format: """}}}}}

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [November 1, 2018, 9:44am UTC](https://discuss.elastic.co/t/error-while-sending-data-from-mysql-to-logstash/154908/2 "2018-11-01T09:44:51Z")

</div>

> [@emma1](#):
>
> "\_id"=\>"PPROy2YBBHN1pAdlFGMy", "status"=\>400, "error"=\>{"type"=\>"mapper\_parsing\_exception", "reason"=\>"failed to parse [execution month]", "caused\_by"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"Invalid format: """}}}}}

This part of the error message looks like there is a problem with the date format setting in your target index. Can you post the mapping you have in Elasticsearch for the "hybriswaiting\_database" index? You should get it with something like

```auto
curl -X GET "<your_es_adress:your_port>/<your_indec_name>/_mapping"

```

---

<div class="post-metadata">

**Author:** ![emma1](https://avatars.discourse-cdn.com/v4/letter/e/74df32/32.png) [@emma1](https://discuss.elastic.co/u/emma1)\
**Post date:** [November 1, 2018, 12:12pm UTC](https://discuss.elastic.co/t/error-while-sending-data-from-mysql-to-logstash/154908/3 "2018-11-01T12:12:22Z")

</div>

{"hybriswaiting\_database":{"mappings":{"doc":{"properties":{"@timestamp":{"type":"date"},"@version":{"type":"text","fields":{"keyword":{"type":"keyword","ignore\_above":256}}},"action":{"type":"text","fields":{"keyword":{"type":"keyword","ignore\_above":256}}},"ai\_id":{"type":"long"},"date":{"type":"date"},"execution month":{"type":"date"},"execution time":{"type":"text","fields":{"keyword":{"type":"keyword","ignore\_above":256}}},"processcode":{"type":"text","fields":{"keyword":{"type":"keyword","ignore\_above":256}}},"region":{"type":"text","fields":{"keyword":{"type":"keyword","ignore\_above":256}}}}}}}}

this is the one im getting

when "execution month" column is empty logstash is not taking that particular row

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [November 2, 2018, 9:32am UTC](https://discuss.elastic.co/t/error-while-sending-data-from-mysql-to-logstash/154908/4 "2018-11-02T09:32:15Z")

</div>

> [@emma1](#):
>
> "execution month":{"type":"date"}

This means your index is expecting a "date" with the [default format](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html), which is "strict\_date\_optional\_time||epoch\_millis", so you can index date strings like `2015-01-01` or `2015-01-01T12:10:30Z` or plain unix time milliseconds like `1420070400001` but not something that is just a year and month. In order to do that you need to specify a different "format" when the index mapping is created. In the case of Logstash this is sometimes done via and [index template](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html), but might also be done manually by yourself. Another option would be to convert your YYYY-MM date to YYYY-MM-01 somewhere in your Logstash pipeline.

---

<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:** [November 30, 2018, 9:32am UTC](https://discuss.elastic.co/t/error-while-sending-data-from-mysql-to-logstash/154908/5 "2018-11-30T09:32:15Z")

</div>

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