# How to get grok filter from variable

**URL:** <https://discuss.elastic.co/t/how-to-get-grok-filter-from-variable/118511>\
**Category:** Logstash\
**Created:** [February 5, 2018, 6:40pm UTC](https://discuss.elastic.co/t/how-to-get-grok-filter-from-variable/118511 "2018-02-05T18:40:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfur](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jfur](https://discuss.elastic.co/u/jfur)\
**Post date:** [February 5, 2018, 6:40pm UTC](https://discuss.elastic.co/t/how-to-get-grok-filter-from-variable/118511/1 "2018-02-05T18:40:09Z")

</div>

I have somewhat of a complex use case where some events have data in their firewall "msg" field that needs to be parsed out (most don't). I have a dictionary file that is parsing out just fine with the kv plugin, but am having a hard time referencing the variable in the grok filter. Can someone tell me what I'm doing wrong to reference this?

if [ec\_grok] {  
grok {  
match =\> ["event\_content", "[ec\_grok]"]  
}  
}

Note "ec\_grok" is the field that has the following "%{DATA} %{IP:source\_ip} %{DATA} %{MAC:srcMac}".

If needed, the full logstash config can be seen in my github:  
[https://github.com/JonFurmanski/logstash/blob/master/examples/sonicwall/logstash.conf](https://github.com/JonFurmanski/logstash/blob/master/examples/sonicwall/logstash.conf)

---

<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:** [February 5, 2018, 9:24pm UTC](https://discuss.elastic.co/t/how-to-get-grok-filter-from-variable/118511/2 "2018-02-05T21:24:15Z")

</div>

Grok expressions with dynamic `%{field}` references aren't supported.

---

<div class="post-metadata">

**Author:** ![jfur](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jfur](https://discuss.elastic.co/u/jfur)\
**Post date:** [February 5, 2018, 10:07pm UTC](https://discuss.elastic.co/t/how-to-get-grok-filter-from-variable/118511/3 "2018-02-05T22:07:13Z")

</div>

Thank you for the clarification. I've gone ahead an opened up a feature request in github

[https://github.com/elastic/logstash/issues/9099](https://github.com/elastic/logstash/issues/9099)

---

<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:** [March 5, 2018, 10:07pm UTC](https://discuss.elastic.co/t/how-to-get-grok-filter-from-variable/118511/4 "2018-03-05T22:07:13Z")

</div>

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