# Prevent logstash from adding fields to json input

**URL:** <https://discuss.elastic.co/t/prevent-logstash-from-adding-fields-to-json-input/167008>\
**Category:** Logstash\
**Created:** [February 4, 2019, 5:30pm UTC](https://discuss.elastic.co/t/prevent-logstash-from-adding-fields-to-json-input/167008 "2019-02-04T17:30:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![reschenburg](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@reschenburg](https://discuss.elastic.co/u/reschenburg)\
**Post date:** [February 4, 2019, 5:30pm UTC](https://discuss.elastic.co/t/prevent-logstash-from-adding-fields-to-json-input/167008/1 "2019-02-04T17:30:54Z")

</div>

Hi  
I've got a simple setup with a tcp input and kafka output.

```
input {
  tcp {
    port => "${TCP_PORT:1514}"
    codec => json
  }
}

output {
  stdout { codec => rubydebug }
  kafka {
    bootstrap_servers => "${KAFKA_BROKERS}"
    topic_id => "${KAFKATOPIC}"
    codec => json
  }
}

```

I'm sending some simple json:  
{  
"name": "test\_message\_1",  
"identifier": "randomID"  
}

All I want to see in kafka is the same message as I'm putting into logstash. no @Version, no @Timestamp.

What I am getting out however is:  
`{"name":"test_message_1","identifier":"008b8469-287c-4d52-adfc-6821f06af411","host":"XXX.XXX.XXX.XXX","port":54122,"@timestamp":"2019-02-04T17:26:24.837Z","@version":"1"}`

I thought I had this working for a while by specifying the codec as json (I've tried json\_lines too), but either something has changed recently or I've missed something previously.

I've recently been using logstash 6.5.3 but have also tried 6.4.3 (that was the version I was using when I first thought I had this working).

My only other config is  
config:  
config.reload.automatic: "true"  
path.config: /usr/share/logstash/pipeline  
path.data: /usr/share/logstash/data  
queue.checkpoint.writes: 1  
queue.drain: "true"  
queue.max\_bytes: 1gb  
queue.type: persisted

Does anybody have any idea whats going on?  
This is doing my head in ☹

Thanks!

---

<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:** [February 4, 2019, 5:40pm UTC](https://discuss.elastic.co/t/prevent-logstash-from-adding-fields-to-json-input/167008/2 "2019-02-04T17:40:33Z")

</div>

If you have no filters then do not both parsing the json, and use a plain codec. For example,

```
output { stdout { codec => plain { format => "%{message}
" } } }
```

---

<div class="post-metadata">

**Author:** ![reschenburg](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@reschenburg](https://discuss.elastic.co/u/reschenburg)\
**Post date:** [February 4, 2019, 6:34pm UTC](https://discuss.elastic.co/t/prevent-logstash-from-adding-fields-to-json-input/167008/3 "2019-02-04T18:34:03Z")

</div>

doesn't work unfortunately ☹ I've tried codec =\> line { format =\> "%{message}"} in the past, same result.

---

<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:** [March 4, 2019, 6:46pm UTC](https://discuss.elastic.co/t/prevent-logstash-from-adding-fields-to-json-input/167008/4 "2019-03-04T18:46:35Z")

</div>

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