# Log JSON decoding errors of TCP input

**URL:** <https://discuss.elastic.co/t/log-json-decoding-errors-of-tcp-input/156156>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [November 10, 2018, 6:09pm UTC](https://discuss.elastic.co/t/log-json-decoding-errors-of-tcp-input/156156 "2018-11-10T18:09:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![njam](https://avatars.discourse-cdn.com/v4/letter/n/4da419/32.png) [@njam](https://discuss.elastic.co/u/njam)\
**Post date:** [November 10, 2018, 6:09pm UTC](https://discuss.elastic.co/t/log-json-decoding-errors-of-tcp-input/156156/1 "2018-11-10T18:09:04Z")

</div>

I'm setting up a Filebeat TCP input, that parses each line as JSON and sends the resulting fields to Elasticsearch.

```auto
filebeat.inputs:
- type: tcp
  host: "0.0.0.0:5000"

processors:
- decode_json_fields:
    fields: ["message"]
    target: ""
    overwrite_keys: true
- drop_fields:
    fields: ["message"]

output.elasticsearch:
  hosts: ['${ES_HOST}']
  username: '${ES_USERNAME}'
  password: '${ES_PASSWORD}'

```

When I send invalid JSON, an empty log entry is sent to Elasticsearch.

```auto
echo '{"test' | nc 127.0.0.1 5000

```

Is there a way to add the JSON decoding error to the log message? I can see the "log" input has an option `add_error_key`, but I can't find something similar for "tcp".

Thanks  
Reto

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [November 12, 2018, 8:55pm UTC](https://discuss.elastic.co/t/log-json-decoding-errors-of-tcp-input/156156/2 "2018-11-12T20:55:25Z")

</div>

With your configuration the parsing is not done in the input, but the processor. Checking the docs and the code I didn't see any support for setting an error on failure. Please open an [enhancement request](https://github.com/elastic/beats/issues).

---

<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 10, 2018, 8:55pm UTC](https://discuss.elastic.co/t/log-json-decoding-errors-of-tcp-input/156156/3 "2018-12-10T20:55:30Z")

</div>

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