# Send Logstash JSON to python

**URL:** <https://discuss.elastic.co/t/send-logstash-json-to-python/147758>\
**Category:** Logstash\
**Created:** [September 7, 2018, 7:12pm UTC](https://discuss.elastic.co/t/send-logstash-json-to-python/147758 "2018-09-07T19:12:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![neslog](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@neslog](https://discuss.elastic.co/u/neslog)\
**Post date:** [September 7, 2018, 7:12pm UTC](https://discuss.elastic.co/t/send-logstash-json-to-python/147758/1 "2018-09-07T19:12:30Z")

</div>

I'm trying to take the JSON output form Logstash and read it in with Python. Specifically I have the following configuration.

WinLogBeat --\> JSON --\> Logstash Beats receiver --\> output to file

That all works well. When I try to parse the JSON output with python I keep getting Extra data errors. I've been searching around and everything looks like it's more focused on sending logs to logstash from python.

Please link me to any work already done. Any specific trips on getting Logstash JSON output parsed by python?

Thanks in advance for the help!

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [September 7, 2018, 10:31pm UTC](https://discuss.elastic.co/t/send-logstash-json-to-python/147758/2 "2018-09-07T22:31:06Z")

</div>

What does your pipeline's output configuration look like? What codec is being used?

I presume that you're using the `json_lines` codec, which outputs the events as a series of newline-delimited JSON blobs; this format also called [`jsonlines`](http://jsonlines.org/) or [`ndjson`](http://ndjson.org/) (Newline-Delimtied JSON).

If this is the case, when you're consuming in your python application, you'll need to _split_ the input on the newline character before passing each chunk to a JSON parser. There is a python plugin that will do this for you called [`jsonlines`](https://jsonlines.readthedocs.io/en/latest/).

---

<div class="post-metadata">

**Author:** ![neslog](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@neslog](https://discuss.elastic.co/u/neslog)\
**Post date:** [September 8, 2018, 10:30pm UTC](https://discuss.elastic.co/t/send-logstash-json-to-python/147758/3 "2018-09-08T22:30:12Z")

</div>

yaauie - that was it! Thanks.

---

<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:** [October 6, 2018, 10:30pm UTC](https://discuss.elastic.co/t/send-logstash-json-to-python/147758/4 "2018-10-06T22:30:22Z")

</div>

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