# Create a global patterns\_dir

**URL:** <https://discuss.elastic.co/t/create-a-global-patterns-dir/108898>\
**Category:** Logstash\
**Created:** [November 23, 2017, 1:44pm UTC](https://discuss.elastic.co/t/create-a-global-patterns-dir/108898 "2017-11-23T13:44:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vafa\_Ronaghi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vafa_ronaghi/32/43519_2.png) [@Vafa\_Ronaghi](https://discuss.elastic.co/u/Vafa_Ronaghi)\
**Post date:** [November 23, 2017, 1:44pm UTC](https://discuss.elastic.co/t/create-a-global-patterns-dir/108898/1 "2017-11-23T13:44:16Z")

</div>

Hello,

Is it possible to define a global patterns\_dir for all cases in filter or it must be defined in each grok section.

Se below:

```
   if ("xxx" in [path]) {
      grok {
        **patterns_dir => ["/usr/share/logstash/patterns"]**
        match => { "message" => "^%{TIMESTAMP_ISO8601:timestamp}\;%{LOGLEVEL:loglevel}(.*);%{OPTIONALUSERNAME:user};%{TNR:tnr};%{INTEGRATION:integration};%{THREAD:thread};%{WORD:classname};%{GREEDYDATA:logmessage}$" }
        add_field => ["logtype", "xxx"]
      }
    }
    if ("yyy" in [path]) {
      grok {
        **patterns_dir => ["/usr/share/logstash/patterns"]**
        match => { "message" => "^%{TIMESTAMP_ISO8601:timestamp}\;%{LOGLEVEL:loglevel}(.*);%{OPTIONALUSERNAME:user};%{TNR:tnr};%{INTEGRATION:integration};%{THREAD:thread};%{WORD:classname};%{GREEDYDATA:logmessage}$" }
        add_field => ["logtype", "yyy"]
      }
    }
```

---

<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:** [November 23, 2017, 2:25pm UTC](https://discuss.elastic.co/t/create-a-global-patterns-dir/108898/2 "2017-11-23T14:25:05Z")

</div>

You'll have to define it everywhere.

In this case I don't understand why you have two grok filters.

---

<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:** [December 21, 2017, 2:25pm UTC](https://discuss.elastic.co/t/create-a-global-patterns-dir/108898/3 "2017-12-21T14:25:29Z")

</div>

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