# Can logstash be limited by subdirectories?

**URL:** <https://discuss.elastic.co/t/can-logstash-be-limited-by-subdirectories/252917>\
**Category:** Logstash\
**Created:** [October 22, 2020, 1:06am UTC](https://discuss.elastic.co/t/can-logstash-be-limited-by-subdirectories/252917 "2020-10-22T01:06:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GetYourSh1tTogether](https://avatars.discourse-cdn.com/v4/letter/g/f1d935/32.png) [@GetYourSh1tTogether](https://discuss.elastic.co/u/GetYourSh1tTogether)\
**Post date:** [October 22, 2020, 1:06am UTC](https://discuss.elastic.co/t/can-logstash-be-limited-by-subdirectories/252917/1 "2020-10-22T01:06:36Z")

</div>

I have a list of subdirectories that are consistent in each directory. Is it possible to limit logstash to only look for those subdirectories and pull data from those? Would something like this work?

```auto
filter {
 if [type] == "log" {
   grok { match => { "path" => "/%{GREEDYDATA}/%{GREEDYDATA}/%{GREEDYDATA}/%{GREEDYDATA:folder}**/subDirectory1"} }
 grok { match => { "path" => "/%{GREEDYDATA}/%{GREEDYDATA}/%{GREEDYDATA}/%{GREEDYDATA:folder}**/subDirectory2"} }
grok { match => { "path" => "/%{GREEDYDATA}/%{GREEDYDATA}/%{GREEDYDATA}/%{GREEDYDATA:folder}**/subDirectory3"} }
   grok { match => { "path" => "%{GREEDYDATA}/{GREEDYDATA:filename}\log.json"} }
 }
}

```

---

<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:** [November 19, 2020, 1:07am UTC](https://discuss.elastic.co/t/can-logstash-be-limited-by-subdirectories/252917/2 "2020-11-19T01:07:06Z")

</div>

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