# Is it possible to mix json and plain text?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-mix-json-and-plain-text/205141>\
**Category:** Beats\
**Tags:** docker, filebeat\
**Created:** [October 24, 2019, 7:24pm UTC](https://discuss.elastic.co/t/is-it-possible-to-mix-json-and-plain-text/205141 "2019-10-24T19:24:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikael\_Elkiaer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikael_elkiaer/32/43038_2.png) [@Mikael\_Elkiaer](https://discuss.elastic.co/u/Mikael_Elkiaer)\
**Post date:** [October 24, 2019, 7:24pm UTC](https://discuss.elastic.co/t/is-it-possible-to-mix-json-and-plain-text/205141/1 "2019-10-24T19:24:48Z")

</div>

I use filebeat to grab my Docker logs. Most of these are plain text. However, for self-created services I like to use Serilog for structured logging and it therefore formats the logs in elasticsearch format.

Is it possible to somehow enable json decoding partially, and let non-json logs go through as though json decoding wasn't enabled? Possibly by configuring multiple container inputs and filtering appropriately?

I already tried enabling json decoding, but then all non-json logs will result in an elasticsearch error, which ironically also fails as the log message is a cropped json body.

---

<div class="post-metadata">

**Author:** ![pmercado](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@pmercado](https://discuss.elastic.co/u/pmercado)\
**Post date:** [October 25, 2019, 12:26pm UTC](https://discuss.elastic.co/t/is-it-possible-to-mix-json-and-plain-text/205141/2 "2019-10-25T12:26:18Z")

</div>

Hi @Mikael_Elkiaer,

would adding some conditions as depicted here:  
[https://www.elastic.co/guide/en/beats/filebeat/current/defining-processors.html](https://www.elastic.co/guide/en/beats/filebeat/current/defining-processors.html)

for the json processor help?  
you could conditionally apply the json decoding based on the fetched fields.

---

<div class="post-metadata">

**Author:** ![Mikael\_Elkiaer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikael_elkiaer/32/43038_2.png) [@Mikael\_Elkiaer](https://discuss.elastic.co/u/Mikael_Elkiaer)\
**Post date:** [October 25, 2019, 2:30pm UTC](https://discuss.elastic.co/t/is-it-possible-to-mix-json-and-plain-text/205141/3 "2019-10-25T14:30:44Z")

</div>

That's what I was hoping you could tell me.  
How would I add such a processor so that it would send the message as is if it is plain text, or decode the message if it is json?

---

<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:** [November 22, 2019, 2:31pm UTC](https://discuss.elastic.co/t/is-it-possible-to-mix-json-and-plain-text/205141/4 "2019-11-22T14:31:07Z")

</div>

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