# \[HELP?\] Can only import last entry using JDBC with Logstash and ES

**URL:** <https://discuss.elastic.co/t/help-can-only-import-last-entry-using-jdbc-with-logstash-and-es/55283>\
**Category:** Logstash\
**Created:** [July 12, 2016, 10:32am UTC](https://discuss.elastic.co/t/help-can-only-import-last-entry-using-jdbc-with-logstash-and-es/55283 "2016-07-12T10:32:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nindy876](https://avatars.discourse-cdn.com/v4/letter/n/5f9b8f/32.png) [@Nindy876](https://discuss.elastic.co/u/Nindy876)\
**Post date:** [July 12, 2016, 10:32am UTC](https://discuss.elastic.co/t/help-can-only-import-last-entry-using-jdbc-with-logstash-and-es/55283/1 "2016-07-12T10:32:42Z")

</div>

So I'm new to ELK and I'm trying to import data from a postgres DB into ES for searching within Kibana.

I have the JDBC plugin all set up and I have a config file to import data. It runs fine but I only seem to get the last entry from the postgres database appear in kibana. I want all the data in there.

Here is my config file:

# file: test.conf

input {  
jdbc {  
# Postgres jdbc connection string to test database, raptor\_db  
jdbc\_connection\_string =\> "jdbc:postgresql://localhost:5433/raptor\_db"  
# the user we wish to execute our statement as  
jdbc\_user =\> "**_"  
jdbc\_password =\> "_**"  
# the path to our downloaded jdbc driver  
jdbc\_driver\_library =\> "/postgresql-9.4.1208.jre6.jar"  
# name of the driver class for Postgresql  
jdbc\_driver\_class =\> "org.postgresql.Driver"  
#the query  
statement =\> "SELECT \* from prefetch"  
jdbc\_paging\_enabled =\> true  
}

}

output {  
elasticsearch {  
index =\> "prefetch"  
document\_type =\> "prefetch\_item"  
document\_id =\> "%{uid}"  
hosts =\> "localhost:9200"  
}  
}

Like I said, it imports a single entry just fine but not all of them.

If someone could point me in a good direction I would be very grateful!

thanks,

Andy

---

<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:** [July 12, 2016, 11:07am UTC](https://discuss.elastic.co/t/help-can-only-import-last-entry-using-jdbc-with-logstash-and-es/55283/2 "2016-07-12T11:07:09Z")

</div>

And the uid column is unique for each row in the database?

---

<div class="post-metadata">

**Author:** ![Nindy876](https://avatars.discourse-cdn.com/v4/letter/n/5f9b8f/32.png) [@Nindy876](https://discuss.elastic.co/u/Nindy876)\
**Post date:** [July 12, 2016, 12:19pm UTC](https://discuss.elastic.co/t/help-can-only-import-last-entry-using-jdbc-with-logstash-and-es/55283/3 "2016-07-12T12:19:32Z")

</div>

This was the problem, my "document\_id" field was wrong. I actually just removed it and it sorted the problem out.

thanks magnusbaeck for getting back so quickly!

---

<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:** [July 6, 2017, 4:48am UTC](https://discuss.elastic.co/t/help-can-only-import-last-entry-using-jdbc-with-logstash-and-es/55283/4 "2017-07-06T04:48:26Z")

</div>


