# Filebeat - how control level nested json object parsing - decode\_json\_fields

**URL:** https://discuss.elastic.co/t/filebeat-how-control-level-nested-json-object-parsing-decode-json-fields/162876
**Category:** Beats
**Created:** [January 3, 2019, 10:23pm UTC](https://discuss.elastic.co/t/filebeat-how-control-level-nested-json-object-parsing-decode-json-fields/162876 "2019-01-03T22:23:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![azhurbilo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/azhurbilo/32/39408_2.png) [@azhurbilo](https://discuss.elastic.co/u/azhurbilo)
#### Post date: [January 3, 2019, 10:23pm UTC](https://discuss.elastic.co/t/filebeat-how-control-level-nested-json-object-parsing-decode-json-fields/162876/1 "2019-01-03T22:23:03Z")

</div>

Filebeat - how can I control level of decode\_json\_fields ?  
max\_depth seems not help in my case ☹

goal: parsing `'/var/lib/docker/containers/*/*.log'` but controlling max json depth

```auto
name: "host-01"
queue:
  mem:
    events: 16384
    # batch of events to the outputs. "0" ensures events are immediately available to be sent to the outputs.
    flush.min_events: 0

filebeat:
  prospectors:
    - type: log
      paths:
       - '/tmp/test.log'
      json:
        # key on which to apply the line filtering and multiline settings
        message_key: log
        keys_under_root: true
        add_error_key: true
      processors:
      - decode_json_fields:
          fields: ["log"]
          process_array: false
          max_depth: 1
          overwrite_keys: false

output:
  console:
    pretty: true

```

Example

> echo '{"log":"{ "status": { "foo": { "bar": 1 } }, "bytes\_sent": "0", "gzip\_ratio": "-", "hostname": "cb7b5441f0da" }\n","stream":"stdout","time":"2018-12-29T11:25:36.130729806Z"}' \>\> /tmp/test.log

Actual result:

```auto
{
...
  "log": {
    "status": {
      "foo": {
        "bar": 1
      }
    },
    "bytes_sent": "0",
    "gzip_ratio": "-",
    "hostname": "cb7b5441f0da"
...
}

```

Expected result:

```auto
{
...
  "log": {
    "status": "{ \"foo\": { \"bar\": 1 } }"
   },
  "bytes_sent": "0",
  "gzip_ratio": "-",
  "hostname": "cb7b5441f0da"
...
}

```

How to control nested json objects?

here is some explanation [max\_depth nested json not working · Issue #9834 · elastic/beats · GitHub](https://github.com/elastic/beats/issues/9834#issuecomment-451134008)  
but removing `json:` and leave only `decode_json_fields` doesn't help

---

<div class="post-metadata">

### Author: ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)
#### Post date: [January 4, 2019, 10:47am UTC](https://discuss.elastic.co/t/filebeat-how-control-level-nested-json-object-parsing-decode-json-fields/162876/2 "2019-01-04T10:47:02Z")

</div>

Your example JSON could not be parsed unless I removed `"` around the value of `log`.  
However, the processor seems to ignore `max_depth` option. I need a bit more time to investigate the issue. Thank you for your patience.

---

<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: [February 1, 2019, 12:47pm UTC](https://discuss.elastic.co/t/filebeat-how-control-level-nested-json-object-parsing-decode-json-fields/162876/3 "2019-02-01T12:47:03Z")

</div>

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