# Ruby error when replacing @timestamp

**URL:** https://discuss.elastic.co/t/ruby-error-when-replacing-timestamp/122917
**Category:** Logstash
**Created:** [March 7, 2018, 3:58pm UTC](https://discuss.elastic.co/t/ruby-error-when-replacing-timestamp/122917 "2018-03-07T15:58:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Anabella\_Cristaldi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anabella_cristaldi/32/23612_2.png) [@Anabella\_Cristaldi](https://discuss.elastic.co/u/Anabella_Cristaldi)
#### Post date: [March 7, 2018, 3:58pm UTC](https://discuss.elastic.co/t/ruby-error-when-replacing-timestamp/122917/1 "2018-03-07T15:58:02Z")

</div>

Hi,  
I need to set the @timestamp field to date contained in another field of my log  
(instead of using the default indexation time)  
I tried to use the date filter pluging in combination with ruby plugin  
Using this code

```
date {
        match => ["ts", "yyyyMMddHHmmss"]
        timezone => "UTC"
        target => "ts_temp"
}

ruby {
        code => "event.set('@timestamp',event.get('ts_temp'))"
}

```

I get  
Ruby exception occurred: wrong argument type NilClass (expected LogStash::Timestamp)

What I'm doing wrong?  
Thank you very much  
Regards  
Anna

---

<div class="post-metadata">

### Author: ![Anabella\_Cristaldi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anabella_cristaldi/32/23612_2.png) [@Anabella\_Cristaldi](https://discuss.elastic.co/u/Anabella_Cristaldi)
#### Post date: [March 7, 2018, 4:11pm UTC](https://discuss.elastic.co/t/ruby-error-when-replacing-timestamp/122917/2 "2018-03-07T16:11:58Z")

</div>

My fault, it is not need to use the ruby plugin, just date plugin

```
date {
        match => ["ts", "yyyyMMddHHmmss"]
        timezone => "UTC"
}

```

Regards  
Ana

---

<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: [April 4, 2018, 4:12pm UTC](https://discuss.elastic.co/t/ruby-error-when-replacing-timestamp/122917/3 "2018-04-04T16:12:06Z")

</div>

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