# Get Foldername from file sent by filebeat

**URL:** <https://discuss.elastic.co/t/get-foldername-from-file-sent-by-filebeat/64280>\
**Category:** Logstash\
**Created:** [October 28, 2016, 12:43pm UTC](https://discuss.elastic.co/t/get-foldername-from-file-sent-by-filebeat/64280 "2016-10-28T12:43:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![txisme](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@txisme](https://discuss.elastic.co/u/txisme)\
**Post date:** [October 28, 2016, 12:43pm UTC](https://discuss.elastic.co/t/get-foldername-from-file-sent-by-filebeat/64280/1 "2016-10-28T12:43:00Z")

</div>

How can i get the folder name of a file sent by filebeat??

i tried this:  
\> grok {  
\> path =\> "/path/to/folder/%{WORD:foldername}/%{GREEDYDATA}"  
\> }

but it s not working 😕

---

<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:** [October 29, 2016, 8:00pm UTC](https://discuss.elastic.co/t/get-foldername-from-file-sent-by-filebeat/64280/2 "2016-10-29T20:00:37Z")

</div>

That's not what a grok filter looks like. It has the following form:

```nohighlight
grok {
  match => {
    "name of field to match against" => "grok expression"
  }
}

```

There are concrete examples in the documentation.

---

<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 6, 2017, 4:32am UTC](https://discuss.elastic.co/t/get-foldername-from-file-sent-by-filebeat/64280/3 "2017-07-06T04:32:03Z")

</div>


