# Ok to define custom grok patterns in default logstash pattern file?

**URL:** <https://discuss.elastic.co/t/ok-to-define-custom-grok-patterns-in-default-logstash-pattern-file/198789>\
**Category:** Logstash\
**Created:** [September 9, 2019, 8:59pm UTC](https://discuss.elastic.co/t/ok-to-define-custom-grok-patterns-in-default-logstash-pattern-file/198789 "2019-09-09T20:59:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hueyg](https://avatars.discourse-cdn.com/v4/letter/h/8c91f0/32.png) [@hueyg](https://discuss.elastic.co/u/hueyg)\
**Post date:** [September 9, 2019, 8:59pm UTC](https://discuss.elastic.co/t/ok-to-define-custom-grok-patterns-in-default-logstash-pattern-file/198789/1 "2019-09-09T20:59:53Z")

</div>

Is there any problem with defining a custom expression in the already existing pattern file that I believe is read here in version 7.2:

/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-patterns-core-4.1.2/patterns/grok-patterns

I wouldn't think so, but assuming before has nailed me.

Thanks for everyone's help as always.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 9, 2019, 9:09pm UTC](https://discuss.elastic.co/t/ok-to-define-custom-grok-patterns-in-default-logstash-pattern-file/198789/2 "2019-09-09T21:09:10Z")

</div>

That could get overwritten during an upgrade or re-install, and I do not see any benefit from doing so. Why not create /usr/share/logstash/patterns and add a file containing the pattern there?

---

<div class="post-metadata">

**Author:** ![hueyg](https://avatars.discourse-cdn.com/v4/letter/h/8c91f0/32.png) [@hueyg](https://discuss.elastic.co/u/hueyg)\
**Post date:** [September 9, 2019, 9:19pm UTC](https://discuss.elastic.co/t/ok-to-define-custom-grok-patterns-in-default-logstash-pattern-file/198789/3 "2019-09-09T21:19:20Z")

</div>

Good point. Honestly, there are so many moving parts I was hoping to minimize customization, but you are correct.

That requires the use of the patterns\_dir setting correct?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 9, 2019, 9:23pm UTC](https://discuss.elastic.co/t/ok-to-define-custom-grok-patterns-in-default-logstash-pattern-file/198789/4 "2019-09-09T21:23:08Z")

</div>

> [@hueyg](#):
>
> That requires the use of the patterns\_dir setting correct?

Not in recent versions. It looks in that directory by default

```auto
[2019-09-09T21:07:03,079][DEBUG][logstash.filters.grok] Grok patterns path {:paths=>["/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-patterns-core-4.1.2/patterns", "/usr/share/logstash/patterns/*"]}

```

---

<div class="post-metadata">

**Author:** ![hueyg](https://avatars.discourse-cdn.com/v4/letter/h/8c91f0/32.png) [@hueyg](https://discuss.elastic.co/u/hueyg)\
**Post date:** [September 9, 2019, 9:27pm UTC](https://discuss.elastic.co/t/ok-to-define-custom-grok-patterns-in-default-logstash-pattern-file/198789/5 "2019-09-09T21:27:07Z")

</div>

WHAT! Why does no one tell me these things. That is perfect! Thanks Badger. Exactly what I was looking for.

---

<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:** [October 7, 2019, 9:27pm UTC](https://discuss.elastic.co/t/ok-to-define-custom-grok-patterns-in-default-logstash-pattern-file/198789/6 "2019-10-07T21:27:21Z")

</div>

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