# How to parse mix json logs

**URL:** <https://discuss.elastic.co/t/how-to-parse-mix-json-logs/167594>\
**Category:** Logstash\
**Created:** [February 8, 2019, 9:14am UTC](https://discuss.elastic.co/t/how-to-parse-mix-json-logs/167594 "2019-02-08T09:14:34Z")\
**Posts on this page:** 1\
**Showing post:** 28

<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:** [February 25, 2019, 1:59pm UTC](https://discuss.elastic.co/t/how-to-parse-mix-json-logs/167594/28 "2019-02-25T13:59:54Z")

</div>

If you require a different number of columns for different events then you could use a conditional to decide which csv filter to use. Something like

```
if [message] =~ /.*,.*,.*,.*,.*/
    csv {} # events with 5 fields
else if [message] =~ /.*,.*,.*,.*/
    csv {} # events with 4 fields
[...]
```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-parse-mix-json-logs/167594)._
