# I want to remove nested elements from logs

**URL:** <https://discuss.elastic.co/t/i-want-to-remove-nested-elements-from-logs/333979>\
**Category:** Logstash\
**Created:** [May 22, 2023, 6:58am UTC](https://discuss.elastic.co/t/i-want-to-remove-nested-elements-from-logs/333979 "2023-05-22T06:58:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayushi\_bhardwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayushi_bhardwaj/32/109915_2.png) [@Ayushi\_bhardwaj](https://discuss.elastic.co/u/Ayushi_bhardwaj)\
**Post date:** [May 22, 2023, 6:58am UTC](https://discuss.elastic.co/t/i-want-to-remove-nested-elements-from-logs/333979/1 "2023-05-22T06:58:59Z")

</div>

i want to remove nested elements from logs

```auto
"x": {
     "test": {
        "rulesetname": "eq",
        "operation": {
          "name": "diagnosticresult",
          "version": "235"
        },
        "device": "string",
        "rulesetversion": "16.0",
        "runtimes": {
          "ray": 22,
          "overall": 119,
          "output": 24,
          "dispatch": -1,
          "storeget": -1,
          "ruleset": 62,
          "storeput": -1
        },
        "destination": "string",
        "sync": false,
        "partnumber": "xxxx",
        "trackingid": "xxxxxx",
        "triggerreasons": "9 10 ",
        "cc": "229",
        "raystatus": "OK"
      },
      "k8s": {
        "clustername": "test1",
        "containername": "test2",
        "port": 32808,
        "workernode": "xyz
        "namespacename": "abc",
        "podname": "abccc"
      },
      "logmessagesizeinbytes": 538
    } }

```

we want to remove x.test & x.k8s we tried removing by using remove\_field =\> ["[test][0]"]  
but this does not work and we dont get the expected results. Could you please help with way to remove

---

<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:** [May 22, 2023, 5:49pm UTC](https://discuss.elastic.co/t/i-want-to-remove-nested-elements-from-logs/333979/2 "2023-05-22T17:49:11Z")

</div>

They are not arrays so the [0] is not needed. Try

```
mutate { remove_field => ["[x][test]", "[x][k8s]" ] }

```

---

<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:** [June 19, 2023, 5:49pm UTC](https://discuss.elastic.co/t/i-want-to-remove-nested-elements-from-logs/333979/3 "2023-06-19T17:49:15Z")

</div>

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