# Logstash JDBC plugin question

**URL:** https://discuss.elastic.co/t/logstash-jdbc-plugin-question/41586
**Category:** Logstash
**Created:** [February 12, 2016, 9:19am UTC](https://discuss.elastic.co/t/logstash-jdbc-plugin-question/41586 "2016-02-12T09:19:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jaminvp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaminvp/32/5868_2.png) [@jaminvp](https://discuss.elastic.co/u/jaminvp)
#### Post date: [February 12, 2016, 9:19am UTC](https://discuss.elastic.co/t/logstash-jdbc-plugin-question/41586/1 "2016-02-12T09:19:23Z")

</div>

Greetings,

Presume I have a database table containing status info about processing jobs.

This table would have the following columns with an example rule:

JobID - Jobname - RunDate - Status - StartTimestamp - EndTimestamp - Other informative columns

* * *

1 - job - 10/02/2016 - WAITING - 10:00 - 10:05 - ...

Now presume I have the logstash JDBC plugin running a query periodically to select all jobs with their statusinfo. How would an update of the job status of this row (WAITING --\> SUCCEEDED) in the database table affect Elasticsearch? Would a log with a different statusupdate be inserted into Elasticsearch or would the existing log be updated?

---

<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: [February 14, 2016, 12:01pm UTC](https://discuss.elastic.co/t/logstash-jdbc-plugin-question/41586/2 "2016-02-14T12:01:34Z")

</div>

Whichever you prefer. By default each event passing through Logstash will result in a new document in ES, but you can override that behavior by setting the elasticsearch output's [`document_id` option](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-document_id) to choose the id of the document to index or update. For example, if the database table's JobID column is a suitable primary key in the ES index you should be able to do this to keep the job's information updated:

```ruby
elasticsearch {
  ...
  document_id => "%{JobID}"
}

```

---

<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, 5:11am UTC](https://discuss.elastic.co/t/logstash-jdbc-plugin-question/41586/3 "2017-07-06T05:11:38Z")

</div>


