# Tail database table entries

**URL:** <https://discuss.elastic.co/t/tail-database-table-entries/78375>\
**Category:** Logstash\
**Created:** [March 13, 2017, 3:39pm UTC](https://discuss.elastic.co/t/tail-database-table-entries/78375 "2017-03-13T15:39:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggajanan](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@ggajanan](https://discuss.elastic.co/u/ggajanan)\
**Post date:** [March 13, 2017, 3:39pm UTC](https://discuss.elastic.co/t/tail-database-table-entries/78375/1 "2017-03-13T15:39:51Z")

</div>

Hi,

I am using JDBC input in the logstash. The query used in it selects data from a couple of tables. With the initial run, data is extracted using the query and stored in elasticsearch. But if new records are being inserted into the tables involved in the query, is is possible to get that data immediately into elasticsearch?

jdbc {  
type =\> "databaseData"  
jdbc\_driver\_library =\> "C:\tools\ELK5\logstash-5.2.2\jdbc-drivers\db2jcc4.jar"  
jdbc\_driver\_class =\> "com.ibm.db2.jcc.DB2Driver"  
jdbc\_connection\_string =\> "jdbc:db2://localhost:50000/UBDB"  
jdbc\_user =\> "dbuser"  
jdbc\_password =\> "dbpass"  
statement\_filepath =\> "C:\tools\ELK5\logstash-5.2.2\query\transfer.sql"  
jdbc\_fetch\_size =\> 5   
}

Thanks,  
Gajanan

---

<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:** [March 14, 2017, 6:37am UTC](https://discuss.elastic.co/t/tail-database-table-entries/78375/2 "2017-03-14T06:37:50Z")

</div>

You can schedule the jdbc input to run at arbitrary intervals. The plugin provides a `sql_last_value` parameter that you can use in your query to only select rows that are more recent than the last row that was fetched last time. This requires that you have a "last modified" column or similar so that it's easy to find the rows that should be fed into ES. This is described in the documentation.

---

<div class="post-metadata">

**Author:** ![ggajanan](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@ggajanan](https://discuss.elastic.co/u/ggajanan)\
**Post date:** [March 14, 2017, 9:25pm UTC](https://discuss.elastic.co/t/tail-database-table-entries/78375/3 "2017-03-14T21:25:02Z")

</div>

> [@magnusbaeck](#):
>
> an schedule the jdbc input to run at arbitrary intervals. The plugin provides a sql\_last\_value parameter that you can use in your query to only select rows that are

I will try that. Thank you so much!

---

<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:** [April 11, 2017, 9:25pm UTC](https://discuss.elastic.co/t/tail-database-table-entries/78375/4 "2017-04-11T21:25:13Z")

</div>

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