# How can I set current time in field

**URL:** https://discuss.elastic.co/t/how-can-i-set-current-time-in-field/157542
**Category:** Logstash
**Created:** [November 20, 2018, 12:22pm UTC](https://discuss.elastic.co/t/how-can-i-set-current-time-in-field/157542 "2018-11-20T12:22:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![2501492a6edd02b1386b](https://avatars.discourse-cdn.com/v4/letter/2/9de0a6/32.png) [@2501492a6edd02b1386b](https://discuss.elastic.co/u/2501492a6edd02b1386b)
#### Post date: [November 20, 2018, 12:22pm UTC](https://discuss.elastic.co/t/how-can-i-set-current-time-in-field/157542/1 "2018-11-20T12:22:25Z")

</div>

Hi,  
Could you please share with me info how I can to set current system time in field "@timestamp".  
In my case, I successfully copy field with @timestamp in filed "real\_timestamp".  
And then I would like to set @timestamp with system time of the server we logstash running.

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 20, 2018, 2:01pm UTC](https://discuss.elastic.co/t/how-can-i-set-current-time-in-field/157542/2 "2018-11-20T14:01:40Z")

</div>

You could try the following:

```
    ruby { 
         code => "event.set('systemtime', Time.now());"
    }
```

---

<div class="post-metadata">

### Author: ![2501492a6edd02b1386b](https://avatars.discourse-cdn.com/v4/letter/2/9de0a6/32.png) [@2501492a6edd02b1386b](https://discuss.elastic.co/u/2501492a6edd02b1386b)
#### Post date: [November 21, 2018, 10:11am UTC](https://discuss.elastic.co/t/how-can-i-set-current-time-in-field/157542/3 "2018-11-21T10:11:07Z")

</div>

Hi guys,  
Thanx @Eniqmatic  
I've done this job with the following config:

```
 mutate {
    add_field => { "realtimestamp" => "%{@timestamp}" }
        }

      ruby {
        code => "event.set('logstash_processed_at', Time.now());"
        }

    mutate {
    convert => { "logstash_processed_at" => "string" }
        }

    date {
    match => ["logstash_processed_at", "ISO8601"]
    target => "@timestamp"
    add_tag => "timestamp_changed"
    }
```

---

<div class="post-metadata">

### Author: ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)
#### Post date: [November 21, 2018, 10:19am UTC](https://discuss.elastic.co/t/how-can-i-set-current-time-in-field/157542/4 "2018-11-21T10:19:44Z")

</div>

Correct well done!

Please mark as solved! 🙂

---

<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: [December 19, 2018, 10:19am UTC](https://discuss.elastic.co/t/how-can-i-set-current-time-in-field/157542/5 "2018-12-19T10:19:48Z")

</div>

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