# Expected json encoding for TCP input?

**URL:** <https://discuss.elastic.co/t/expected-json-encoding-for-tcp-input/172301>\
**Category:** Logstash\
**Created:** [March 14, 2019, 10:00am UTC](https://discuss.elastic.co/t/expected-json-encoding-for-tcp-input/172301 "2019-03-14T10:00:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chmike](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chmike/32/41971_2.png) [@chmike](https://discuss.elastic.co/u/chmike)\
**Post date:** [March 14, 2019, 10:00am UTC](https://discuss.elastic.co/t/expected-json-encoding-for-tcp-input/172301/1 "2019-03-14T10:00:11Z")

</div>

I need to implement a client that sends logging records to a logstash instance at a relative high rate (at least 2kHz). https can’t match this requirement. An option is to use the TCP input plugin, but I failed to find a documentation on the data this plugin expect to receive as input. All I could find is that it expect to receive json input.

Do I send json objects separated by commas ? Are newlines allowed inside the json object ? Where can or should I have newlines ? Is there a handshake or the data flow is one way only ?

Does the TCP TLS support client certificate authentication ? Is there any authentication method beyond that ?

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [March 14, 2019, 4:14pm UTC](https://discuss.elastic.co/t/expected-json-encoding-for-tcp-input/172301/2 "2019-03-14T16:14:40Z")

</div>

IIRC the tcp input with the json codec expects one JSON Object per line (not pretty printed) - i.e. JSON Objects, string encoded (UTF-8) with a trailing newline.

TLS yes. [https://github.com/logstash-plugins/logstash-input-tcp/issues?utf8=✓&q=is%3Aissue+tls](https://github.com/logstash-plugins/logstash-input-tcp/issues?utf8=%E2%9C%93&q=is%3Aissue+tls)

---

<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:** [March 14, 2019, 4:21pm UTC](https://discuss.elastic.co/t/expected-json-encoding-for-tcp-input/172301/3 "2019-03-14T16:21:26Z")

</div>

The tcp input will generate an event every time it sees a new line. It can process JSON or plain text. There is no handshake. If the ssl\_verify option is set to true then it will validate the client certificate against the CA. I think it is then up to you to verify that the sslsubject added to the event is valid.

---

<div class="post-metadata">

**Author:** ![chmike](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chmike/32/41971_2.png) [@chmike](https://discuss.elastic.co/u/chmike)\
**Post date:** [March 15, 2019, 10:13am UTC](https://discuss.elastic.co/t/expected-json-encoding-for-tcp-input/172301/4 "2019-03-15T10:13:35Z")

</div>

Do I have to pick the codec json\_lines instead of json ?

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [March 15, 2019, 10:38am UTC](https://discuss.elastic.co/t/expected-json-encoding-for-tcp-input/172301/5 "2019-03-15T10:38:32Z")

</div>

You can use either. Using json\_lines may be better "documentation" for when you edit the config months from now 🙂

Behind the scenes the config loader substitutes the json\_lines codec for the json codec when it is specified. For that reason, being explicit is better "documentation".

---

<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 12, 2019, 10:38am UTC](https://discuss.elastic.co/t/expected-json-encoding-for-tcp-input/172301/6 "2019-04-12T10:38:40Z")

</div>

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