# Only write the newest data into ES

**URL:** <https://discuss.elastic.co/t/only-write-the-newest-data-into-es/163168>\
**Category:** Logstash\
**Created:** [January 7, 2019, 9:00am UTC](https://discuss.elastic.co/t/only-write-the-newest-data-into-es/163168 "2019-01-07T09:00:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ErikWarming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/erikwarming/32/39525_2.png) [@ErikWarming](https://discuss.elastic.co/u/ErikWarming)\
**Post date:** [January 7, 2019, 9:01am UTC](https://discuss.elastic.co/t/only-write-the-newest-data-into-es/163168/1 "2019-01-07T09:01:00Z")

</div>

I'm pulling a datafile into elasticsearch  
I'm using [http\_poller](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http_poller.html) with an API and I'm including the metadata where I get a last-modified timestamp for my datafile.

What I want to do is compare the http\_poller timestamp with the timestamp in the ES database and only write the new version of my datafile into ES.  
**The end goal would be that logstash checks the API ones a second, but only grab the datafile when there is an update.** But how do I do that?

My guess is that in the output{} should make a lookup in the ES database, but I can't figure out how. Any suggestions?

```
input {
  http_poller {
    urls => {...}
    metadata_target => "http_poller_metadata"
  }
}

filter {
}

output {
	if API_timestamp > ES_timestamp
		elasticsearch { ... }
  stdout {
    codec => rubydebug
  }
}
```

---

<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:** [February 4, 2019, 9:01am UTC](https://discuss.elastic.co/t/only-write-the-newest-data-into-es/163168/2 "2019-02-04T09:01:09Z")

</div>

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