# Locate json field with jsonpath (logstash)

**URL:** <https://discuss.elastic.co/t/locate-json-field-with-jsonpath-logstash/318812>\
**Category:** Logstash\
**Created:** [November 14, 2022, 12:49am UTC](https://discuss.elastic.co/t/locate-json-field-with-jsonpath-logstash/318812 "2022-11-14T00:49:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [November 14, 2022, 2:35am UTC](https://discuss.elastic.co/t/locate-json-field-with-jsonpath-logstash/318812/2 "2022-11-14T02:35:31Z")

</div>

I would use a ruby filter to find the right entry in the array:

```
    ruby {
        code => '
            begin
                a = event.get("[response][result][0][CHILDMONITORS][0][CHILDMONITORINFO]")
                a = a.select { |x| x["DISPLAYNAME"] == "TotalNodos" }
                event.set("someField", a[0]["CHILDATTRIBUTES"][0]["Value"])
            rescue
            end
        '
    }

```

---

_[View the full topic](https://discuss.elastic.co/t/locate-json-field-with-jsonpath-logstash/318812)._
