# Logstash sync mysql two tables to elasticsearch doesn't work

**URL:** <https://discuss.elastic.co/t/logstash-sync-mysql-two-tables-to-elasticsearch-doesnt-work/212500>\
**Category:** Logstash\
**Created:** [December 19, 2019, 1:31pm UTC](https://discuss.elastic.co/t/logstash-sync-mysql-two-tables-to-elasticsearch-doesnt-work/212500 "2019-12-19T13:31:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hel](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@hel](https://discuss.elastic.co/u/hel)\
**Post date:** [December 19, 2019, 1:31pm UTC](https://discuss.elastic.co/t/logstash-sync-mysql-two-tables-to-elasticsearch-doesnt-work/212500/1 "2019-12-19T13:31:21Z")

</div>

I'm tring to use logstash to synchronize mysql tables to elasticsearch. At first there was only one input for synchronizing table 'article' and went well. Then I appended another input for synchronizing table 'user', but the second index 'user\_index' is not created and data is not imported to elasticsearch.

```
input {
    jdbc {
        jdbc_connection_string => ""
        jdbc_user => ""
        jdbc_password => ""
        schedule => "* * * * *"
        jdbc_validate_connection => true
        jdbc_driver_library => ""
        jdbc_driver_class => "com.mysql.jdbc.Driver"
    	jdbc_paging_enabled => true
    	tracking_column => "unix_ts_in_secs"
    	use_column_value => true
    	tracking_column_type => "numeric"
	    statement => "SELECT *, UNIX_TIMESTAMP(modify_time) AS unix_ts_in_secs FROM article WHERE (UNIX_TIMESTAMP(modify_time) > :sql_last_value AND modify_time < NOW()) ORDER BY modify_time ASC"
	    tags => ["article"]
    }
    
    jdbc {
       jdbc_connection_string => ""
        jdbc_user => ""
        jdbc_password => ""
        schedule => "* * * * *"
        jdbc_validate_connection => true
        jdbc_driver_library => ""
        jdbc_driver_class => "com.mysql.jdbc.Driver"
    	jdbc_paging_enabled => true
    	tracking_column => "unix_ts_in_secs"
    	use_column_value => true
    	tracking_column_type => "numeric"
	    statement => "SELECT id, name, avatar, UNIX_TIMESTAMP(modify_time) AS unix_ts_in_secs FROM user WHERE (UNIX_TIMESTAMP(modify_time) > :sql_last_value AND modify_time < NOW()) ORDER BY modify_time ASC"
    	tags => ["user"]

    }
}

output {
    if "article" in [tags] {
        elasticsearch {
            index => "article_index"
            document_id => "%{id}"
        }
    }

    if "user" in [tags] {
        elasticsearch {
            index => "user_index"
            document_id => "%{id}"
        }
    }

    stdout { 
	    codec => rubydebug
    }
}
```

---

<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:** [January 16, 2020, 1:31pm UTC](https://discuss.elastic.co/t/logstash-sync-mysql-two-tables-to-elasticsearch-doesnt-work/212500/2 "2020-01-16T13:31:26Z")

</div>

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