# Input kafka: the decorate\_events option overwrites @timestamp

**URL:** <https://discuss.elastic.co/t/input-kafka-the-decorate-events-option-overwrites-timestamp/204800>\
**Category:** Logstash\
**Created:** [October 23, 2019, 7:21am UTC](https://discuss.elastic.co/t/input-kafka-the-decorate-events-option-overwrites-timestamp/204800 "2019-10-23T07:21:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeenon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zeenon/32/24883_2.png) [@zeenon](https://discuss.elastic.co/u/zeenon)\
**Post date:** [October 23, 2019, 7:21am UTC](https://discuss.elastic.co/t/input-kafka-the-decorate-events-option-overwrites-timestamp/204800/1 "2019-10-23T07:21:39Z")

</div>

Version: logstash-input-kafka (8.3.1)

- Operating System: Red Hat 7.2
- Logstash: 6.8.1  
I am using decorate\_event in my kafka input section. It works nicely but unfortunatly, in combination with codec json, I lost @timestamp as time of indexation. My @timestamp is the time of recording in Kafka, same as [@metadata][kafka][timestamp] but I have lost the timestamp of indexing in logstash. So I have to rebuild my code in order not to use codec json in the kafka input section. Is it a normal behavior ?  
Thanks for your tips

---

<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:** [October 23, 2019, 1:05pm UTC](https://discuss.elastic.co/t/input-kafka-the-decorate-events-option-overwrites-timestamp/204800/2 "2019-10-23T13:05:41Z")

</div>

If a json codec sees a field in the JSON called @timestamp it will overwrite @timestamp with it. You could use a ruby filter to capture the ingestion time

```
ruby { code => 'event.set("ingestedAt", LogStash::Timestamp.new(Time.now))' }
```

---

<div class="post-metadata">

**Author:** ![zeenon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zeenon/32/24883_2.png) [@zeenon](https://discuss.elastic.co/u/zeenon)\
**Post date:** [October 23, 2019, 1:08pm UTC](https://discuss.elastic.co/t/input-kafka-the-decorate-events-option-overwrites-timestamp/204800/3 "2019-10-23T13:08:27Z")

</div>

it is not the case and if I set decorate\_event to false, @timestamp is correct

---

<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:** [October 23, 2019, 1:56pm UTC](https://discuss.elastic.co/t/input-kafka-the-decorate-events-option-overwrites-timestamp/204800/4 "2019-10-23T13:56:31Z")

</div>

If you look at the [code](https://github.com/logstash-plugins/logstash-input-kafka/blob/32b039ba87d746236075753490d1ab7b3b722b99/lib/logstash/inputs/kafka.rb#L260), decorate\_events just controls whether fields are added to [@metadata][kafka].

---

<div class="post-metadata">

**Author:** ![zeenon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zeenon/32/24883_2.png) [@zeenon](https://discuss.elastic.co/u/zeenon)\
**Post date:** [October 23, 2019, 2:15pm UTC](https://discuss.elastic.co/t/input-kafka-the-decorate-events-option-overwrites-timestamp/204800/5 "2019-10-23T14:15:30Z")

</div>

already checked the code and you're right but if you run a logstash configuration, @timestamp is overwritten

---

<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:** [November 20, 2019, 2:15pm UTC](https://discuss.elastic.co/t/input-kafka-the-decorate-events-option-overwrites-timestamp/204800/6 "2019-11-20T14:15:39Z")

</div>

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