# How to navigate with event,get method of Event API

**URL:** <https://discuss.elastic.co/t/how-to-navigate-with-event-get-method-of-event-api/101306>\
**Category:** Logstash\
**Created:** [September 21, 2017, 10:12am UTC](https://discuss.elastic.co/t/how-to-navigate-with-event-get-method-of-event-api/101306 "2017-09-21T10:12:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkhapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rkhapre/32/48333_2.png) [@rkhapre](https://discuss.elastic.co/u/rkhapre)\
**Post date:** [September 21, 2017, 10:12am UTC](https://discuss.elastic.co/t/how-to-navigate-with-event-get-method-of-event-api/101306/1 "2017-09-21T10:12:10Z")

</div>

Hi

I have a json file , for which i am not able to navigate to the events with logstash 5.0.

I want to extract the name of cars from below  
using get and set method of ruby as per the documentation  
event.get('[message][cars[name]')

```
{
    "name":"John",
    "age":30,
    "cars": [
        { "name":"Ford", "models":["Fiesta", "Focus", "Mustang"] },
        { "name":"BMW", "models":["320", "X3", "X5"] },
        { "name":"Fiat", "models":["500", "Panda"] }
    ]
 }

```

Here is my conf file

```
input {  
      file {
	  
          sincedb_path => "..../bin/sincedb_path.txt"
          path => "..../test1.json"
          type => "test"
          start_position => "beginning"
		  
      }
}

    
filter {

ruby {
    code => "
test = event.get('[message][cars][name]')
event.set('result',test)
	"
	}

}

output {  
stdout { codec => rubydebug}
 
 }

```

With the above config file i get nil value.  
Please let me know correct way to navigate to the path

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 24, 2017, 8:24pm UTC](https://discuss.elastic.co/t/how-to-navigate-with-event-get-method-of-event-api/101306/2 "2017-09-24T20:24:16Z")

</div>

`cars` or `[cars]` addresses the "cars" array itself and `[cars][0][name]` addresses the "name" field of the first item in the array.

---

<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:** [October 22, 2017, 8:24pm UTC](https://discuss.elastic.co/t/how-to-navigate-with-event-get-method-of-event-api/101306/3 "2017-10-22T20:24:37Z")

</div>

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