# Grok filter not working to capture filename

**URL:** https://discuss.elastic.co/t/grok-filter-not-working-to-capture-filename/91197
**Category:** Logstash
**Created:** [June 28, 2017, 9:53pm UTC](https://discuss.elastic.co/t/grok-filter-not-working-to-capture-filename/91197 "2017-06-28T21:53:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Deepthi\_V](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@Deepthi\_V](https://discuss.elastic.co/u/Deepthi_V)
#### Post date: [June 28, 2017, 9:53pm UTC](https://discuss.elastic.co/t/grok-filter-not-working-to-capture-filename/91197/1 "2017-06-28T21:53:31Z")

</div>

Hello,

I have a grok filter that looks like below, which I wrote to capture only the filename from the "path" field.

grok {  
match =\> { "path" =\> "%{GREEDYDATA}/%{GREEDYDATA:filename}.log" }  
add\_field =\> { "file" =\> "%{filename}" }  
#tag\_on\_failure =\> []  
}

But when I run the file, I am getting a \_grokparsefailure in the tags and the filename is not getting captured. Can anybody please help me out here as to what mistake I am doing here?

Thanks,  
Deepthi

---

<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: [June 29, 2017, 5:17am UTC](https://discuss.elastic.co/t/grok-filter-not-working-to-capture-filename/91197/2 "2017-06-29T05:17:46Z")

</div>

Please show an example event that Logstash has processed. Use a `stdout { codec => rubydebug }` output.

---

<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: [July 27, 2017, 5:17am UTC](https://discuss.elastic.co/t/grok-filter-not-working-to-capture-filename/91197/3 "2017-07-27T05:17:52Z")

</div>

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