# Setting patterns\_dir for grok relatively?

**URL:** <https://discuss.elastic.co/t/setting-patterns-dir-for-grok-relatively/117471>\
**Category:** Logstash\
**Created:** [January 29, 2018, 1:48pm UTC](https://discuss.elastic.co/t/setting-patterns-dir-for-grok-relatively/117471 "2018-01-29T13:48:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)\
**Post date:** [January 29, 2018, 1:48pm UTC](https://discuss.elastic.co/t/setting-patterns-dir-for-grok-relatively/117471/1 "2018-01-29T13:48:39Z")

</div>

Hi,

can the patterns\_dir of grok command be set recursively?  
How?

Can I set up a default folder / file for patterns, so that there is no need to set them in each grok filter?

Thanks,  
Andreas

---

<div class="post-metadata">

**Author:** ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)\
**Post date:** [January 30, 2018, 8:46am UTC](https://discuss.elastic.co/t/setting-patterns-dir-for-grok-relatively/117471/2 "2018-01-30T08:46:16Z")

</div>

If you create a directory with a document with all of your patterns in it, defining them each with a name then a regex, you can then point to that folder in your grok filter:

i.e. in make a file in folder /etc/logstash/patterns/patterns (can choose any folder to put this in)

> \<NAME\> \<REGEX\>  
> EXAMPLE .\*  
> EXAMPLE2 [A-Z]\*

```
   grok {
                patterns_dir => "/etc/logstash/patterns/patterns"
.........
   }

```

---

<div class="post-metadata">

**Author:** ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)\
**Post date:** [February 5, 2018, 8:07am UTC](https://discuss.elastic.co/t/setting-patterns-dir-for-grok-relatively/117471/3 "2018-02-05T08:07:13Z")

</div>

Oh, I noticed a wrong translating in my original post / topic.

I did not mean recursively, but I meant relative.  
So how can I set the patterns dir relative to the conf folder, where my filters, inputs and outputs are defined?

Can I set a default, so that I can skip naming the pattern directory each time I call grok?  
Is there a way to define that patterns\_dir by environmental variable?

I am developing locally on windows. Productive system is on linux.

So I have different path structures on both systems. But I don't want need to change all grok patterns directories each time before deploying.

---

<div class="post-metadata">

**Author:** ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)\
**Post date:** [February 15, 2018, 11:53pm UTC](https://discuss.elastic.co/t/setting-patterns-dir-for-grok-relatively/117471/4 "2018-02-15T23:53:38Z")

</div>

Hmmm, not that I know of but you could potentially edit the logstash code itself and add your patterns to the official patterns file. Never done that but that's an option.

---

<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 15, 2018, 11:53pm UTC](https://discuss.elastic.co/t/setting-patterns-dir-for-grok-relatively/117471/5 "2018-03-15T23:53:38Z")

</div>

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