# Nested fields as the grok match input

**URL:** <https://discuss.elastic.co/t/nested-fields-as-the-grok-match-input/192502>\
**Category:** Logstash\
**Created:** [July 26, 2019, 10:07pm UTC](https://discuss.elastic.co/t/nested-fields-as-the-grok-match-input/192502 "2019-07-26T22:07:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbrowe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbrowe/32/99821_2.png) [@jbrowe](https://discuss.elastic.co/u/jbrowe)\
**Post date:** [July 26, 2019, 10:07pm UTC](https://discuss.elastic.co/t/nested-fields-as-the-grok-match-input/192502/1 "2019-07-26T22:07:23Z")

</div>

I am trying to parse ADFS authentication logs from a winlogbeat data stream. My winlogbeat pre-parses these logs by putting everything unrecognized into fields _event\_data.param1_, _event\_data.param2_, etc, which are not meaningful. I'm using a grok filter in Logstash to create meaningful fields in my final index. I have ADFS documents with the following _event\_data.param3_ field pre-parsed by winlogbeat:

`event_data.param3: "jsmith@example.com-The referenced account is currently locked out and may not be logged on to"`

My grok filter configuration, which works for all messages in the debugger, looks like:

```
grok {
     match => {
          [event_data][param3] => [
                 "^%{GREEDYDATA:user_name}-%{GREEDYDATA:reason}"
          ]
     }
}

```

I get no resulting _user\_name_ or _reason_ fields in my index from this configuration and no errors in the logstash logs.

Then I tried to eliminate the nested _event\_data.param3_ reference using the following:

```
mutate {
       add_field => {
            "test_string" => "%{[event_data][param3]}"
       }
}
grok {
     match => {
          test_string => [
                 "^%{GREEDYDATA:user_name}-%{GREEDYDATA:reason}"
          ]
     }
}

```

This works fine. Any clues how I should add nested field names as the string to match in grok?

---

<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:** [July 26, 2019, 11:08pm UTC](https://discuss.elastic.co/t/nested-fields-as-the-grok-match-input/192502/2 "2019-07-26T23:08:10Z")

</div>

> [@jbrowe](#):
>
> grok { match =\> { [event\_data][param3] =\> ["^%{GREEDYDATA:user\_name}-%{GREEDYDATA:reason}"] } }

I am surprised you do not get a syntax error for this one. Instead of

```
grok { match => { [event_data][param3] => ["^%{GREEDYDATA:user_name}-%{GREEDYDATA:reason}"] } }

```

try

```
grok { match => { "[event_data][param3]" => ["^%{GREEDYDATA:user_name}-%{GREEDYDATA:reason}"] } }

```

---

<div class="post-metadata">

**Author:** ![jbrowe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbrowe/32/99821_2.png) [@jbrowe](https://discuss.elastic.co/u/jbrowe)\
**Post date:** [July 26, 2019, 11:19pm UTC](https://discuss.elastic.co/t/nested-fields-as-the-grok-match-input/192502/3 "2019-07-26T23:19:32Z")

</div>

That worked. Thanks. I regularly use:

```
if [event_data][param3] {
   ...
}

```

instead of:

```
if "[event_data][param3]" {
...
}

```

and it works fine.

---

<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:** [July 26, 2019, 11:28pm UTC](https://discuss.elastic.co/t/nested-fields-as-the-grok-match-input/192502/4 "2019-07-26T23:28:21Z")

</div>

I would expect

```
if [event_data][param3] {

```

to work and be surprised if

```
if "[event_data][param3]" {

```

worked. I cannot explain which works where. I guess I have just acclimated to the syntax.

---

<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:** [August 23, 2019, 11:28pm UTC](https://discuss.elastic.co/t/nested-fields-as-the-grok-match-input/192502/5 "2019-08-23T23:28:32Z")

</div>

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