# Logstash filter basted on log file age

**URL:** https://discuss.elastic.co/t/logstash-filter-basted-on-log-file-age/241350
**Category:** Logstash
**Created:** [July 15, 2020, 6:23pm UTC](https://discuss.elastic.co/t/logstash-filter-basted-on-log-file-age/241350 "2020-07-15T18:23:28Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [July 15, 2020, 6:33pm UTC](https://discuss.elastic.co/t/logstash-filter-basted-on-log-file-age/241350/2 "2020-07-15T18:33:02Z")

</div>

Assuming that @timestamp is set to the original date of the log you could do something like

```
ruby { code => 'event.set("[@metadata][age]", Time.now.to_f - event.timestamp.to_f)' }
mutate { convert => { "[@metadata][age]" => "integer" } }
if 172800 < [@metadata][age] {
     # Alternate throttling code
} else {
     # existing throttling
}
```

---

_[View the full topic](https://discuss.elastic.co/t/logstash-filter-basted-on-log-file-age/241350)._
