# How to inject variables to input plugin

**URL:** <https://discuss.elastic.co/t/how-to-inject-variables-to-input-plugin/239597>\
**Category:** Logstash\
**Created:** [July 2, 2020, 9:04am UTC](https://discuss.elastic.co/t/how-to-inject-variables-to-input-plugin/239597 "2020-07-02T09:04:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ohoroyoi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ohoroyoi/32/46820_2.png) [@ohoroyoi](https://discuss.elastic.co/u/ohoroyoi)\
**Post date:** [July 2, 2020, 9:04am UTC](https://discuss.elastic.co/t/how-to-inject-variables-to-input-plugin/239597/1 "2020-07-02T09:04:31Z")

</div>

according to, this answer [https://discuss.elastic.co/t/optimize-logstash-configuration/239574/3](https://discuss.elastic.co/t/optimize-logstash-configuration/239574/3) I realized I have to compare `lastest row date` and `last run date`.

but the problem is I don't know that.

I can find last run date from my $HOME path.

/usr/share/logstash/.logstash\_jdbc\_last\_run

there is a date. like this. `--- 2020-07-02 09:00:00 blahblah`

I think I have to compare this my pg latest row's date column.

how can I get this as a variable in input plugin?

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [July 2, 2020, 5:32pm UTC](https://discuss.elastic.co/t/how-to-inject-variables-to-input-plugin/239597/2 "2020-07-02T17:32:19Z")

</div>

use [sql\_last\_value](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_state) if you want to track last records retrieved by logstash

> [@ohoroyoi](#):
>
> I can find last run date from my $HOME path.
> 
> /usr/share/logstash/.logstash\_jdbc\_last\_run

it’s actually $LS\_HOME rather than your user’s $HOME . LS\_HOME defaults to /usr/share/logstash if you’re using deb / rpm installation

---

<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 30, 2020, 5:40pm UTC](https://discuss.elastic.co/t/how-to-inject-variables-to-input-plugin/239597/3 "2020-07-30T17:40:41Z")

</div>

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