# Repetitive JDBC input runs

**URL:** <https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257>\
**Category:** Logstash\
**Created:** [July 30, 2018, 11:33pm UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257 "2018-07-30T23:33:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![daq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daq/32/33426_2.png) [@daq](https://discuss.elastic.co/u/daq)\
**Post date:** [July 30, 2018, 11:33pm UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/1 "2018-07-30T23:33:19Z")

</div>

We have a stored procedure which returns data for the last hour when called without any parameters. We scheduled the JDBC input plugin to run every hour and it works well. Questions is, if I want to ingest older data I can give a specific date/time to the stored procedure, but what's the best way to do that 300 times?  
I can keep updating config file and restarting logstash, but this would be a pain to automate. Has anyone figured out a better way to take care of similar issue?

Thanks!

---

<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:** [August 1, 2018, 8:43pm UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/2 "2018-08-01T20:43:06Z")

</div>

So the stored procedure always returns rows for a particular hour, but you can supply a parameter to select which hour to return?

---

<div class="post-metadata">

**Author:** ![daq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daq/32/33426_2.png) [@daq](https://discuss.elastic.co/u/daq)\
**Post date:** [August 1, 2018, 9:07pm UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/3 "2018-08-01T21:07:34Z")

</div>

Yes. Something like:

```
call getmedata(NULL); # Current hour
call getmedata("0801140000") # 2:00PM on Aug 1st
```

---

<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:** [August 2, 2018, 6:05am UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/4 "2018-08-02T06:05:35Z")

</div>

I don't see a clean way of doing that. Apart from updating the config file and restarting Logstash you could store the timestamp in an environment variable that you reference in your configuration. That might be slightly easier to automate.

---

<div class="post-metadata">

**Author:** ![daq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daq/32/33426_2.png) [@daq](https://discuss.elastic.co/u/daq)\
**Post date:** [August 2, 2018, 6:45am UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/5 "2018-08-02T06:45:51Z")

</div>

I ended up updating config and restarting Logstash in a loop. Plugins like that desperately need dynamic variables. This way just feels wrong even though it works. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 2, 2018, 1:51pm UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/6 "2018-08-02T13:51:53Z")

</div>

If you start logstash with -r then it will re-read the configuration when it changes. Saves you the huge overhead of restarting logstash for each config change.

---

<div class="post-metadata">

**Author:** ![daq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daq/32/33426_2.png) [@daq](https://discuss.elastic.co/u/daq)\
**Post date:** [August 2, 2018, 2:42pm UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/7 "2018-08-02T14:42:15Z")

</div>

But how would I know when the input completes? My loop simply waits for logstash to exit (after its done reading sql data), updates config and starts logstash again.

I can see how -r could be really helpful in a different situation though.

Thanks.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 2, 2018, 3:01pm UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/8 "2018-08-02T15:01:23Z")

</div>

> [@daq](#):
>
> But how would I know when the input completes?

I do not have a good answer for that.

---

<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:** [August 30, 2018, 3:01pm UTC](https://discuss.elastic.co/t/repetitive-jdbc-input-runs/142257/9 "2018-08-30T15:01:33Z")

</div>

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