# Json + multiline codecs together, is it possible?

**URL:** https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549
**Category:** Logstash
**Tags:** docker
**Created:** [September 14, 2020, 3:09pm UTC](https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549 "2020-09-14T15:09:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Hleb\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hleb_v/32/45013_2.png) [@Hleb\_V](https://discuss.elastic.co/u/Hleb_V)
#### Post date: [September 14, 2020, 3:09pm UTC](https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549/1 "2020-09-14T15:09:51Z")

</div>

Hi.

We are running Java applications inside docker containers. We use `file` input with `json` codec to parse their logs. Unfortunately Java is known to throw stack traces and docker creates a single json entry for every log line. With plain files we can use `multiline` codec to join them into a single event but how to use it with json? It looks like filebeat can be used instead but version 6.8 we have to use now doesn't support other required features, so is it possible to use just `logstash` in this scenario?

---

<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: [September 14, 2020, 3:13pm UTC](https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549/2 "2020-09-14T15:13:01Z")

</div>

You cannot have multiple codecs on a single input. I suggest you use a multiline codec and then a json filter.

---

<div class="post-metadata">

### Author: ![Hleb\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hleb_v/32/45013_2.png) [@Hleb\_V](https://discuss.elastic.co/u/Hleb_V)
#### Post date: [September 14, 2020, 4:01pm UTC](https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549/3 "2020-09-14T16:01:56Z")

</div>

Hi Badger,

could you share example of `input` section for such case?

---

<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: [September 14, 2020, 4:24pm UTC](https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549/4 "2020-09-14T16:24:59Z")

</div>

No, I have no idea what your logs look like, so I cannot guess what configuration you would need to the multiline filter.

---

<div class="post-metadata">

### Author: ![Hleb\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hleb_v/32/45013_2.png) [@Hleb\_V](https://discuss.elastic.co/u/Hleb_V)
#### Post date: [September 14, 2020, 6:49pm UTC](https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549/5 "2020-09-14T18:49:12Z")

</div>

docker logs are typical: `{"log":"log entry begins here (no leading space)","stream":"stdout","time":"iso timestamp"}` and `{"log":" and continues here (there is a leading space)","stream":"stdout","time":"iso timestamp"}`.

If I understand correctly `multiline` codec accepts raw text, so I don't understand how to make it work with json.

---

<div class="post-metadata">

### Author: ![GreenEyed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greeneyed/32/70123_2.png) [@GreenEyed](https://discuss.elastic.co/u/GreenEyed)
#### Post date: [September 15, 2020, 12:20pm UTC](https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549/6 "2020-09-15T12:20:01Z")

</div>

One option would be to send the logs directly to logstash from the application (we use logstash-gelf for that) and then you don't even need to install filebeat in the machines.  
We also send the regular text logs to console so the output is there if the logstash connection fails and someone needs to look at them, but we then rotate them quite aggresively.

---

<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 13, 2020, 12:20pm UTC](https://discuss.elastic.co/t/json-multiline-codecs-together-is-it-possible/248549/7 "2020-10-13T12:20:18Z")

</div>

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