# Get current time using ruby filter in logstash

**URL:** https://discuss.elastic.co/t/get-current-time-using-ruby-filter-in-logstash/90084
**Category:** Logstash
**Created:** [June 20, 2017, 11:00am UTC](https://discuss.elastic.co/t/get-current-time-using-ruby-filter-in-logstash/90084 "2017-06-20T11:00:04Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![jsvd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsvd/32/6203_2.png) [@jsvd](https://discuss.elastic.co/u/jsvd)
#### Post date: [June 20, 2017, 2:10pm UTC](https://discuss.elastic.co/t/get-current-time-using-ruby-filter-in-logstash/90084/8 "2017-06-20T14:10:01Z")

</div>

I was only able to have a similar feature as what you wanted by creating explicit created\_at and updated\_at fields:

```auto
input { stdin { codec => json } }
filter {
  ruby {
    code => "event.set('updated_date', event.get('@timestamp'))"
  }
}
output {
  elasticsearch {
    action => update
    document_id => "%{my_id}"
    upsert => '{ "document_id": "%{my_id}", "value": "%{value}", "created_at": "%{@timestamp}", "updated_at": "%{@timestamp}" }'
  }
}

```

---

_[View the full topic](https://discuss.elastic.co/t/get-current-time-using-ruby-filter-in-logstash/90084)._
