# Same pattern file gives pattern not define for only one pattern

**URL:** <https://discuss.elastic.co/t/same-pattern-file-gives-pattern-not-define-for-only-one-pattern/134368>\
**Category:** Logstash\
**Created:** [June 4, 2018, 7:15am UTC](https://discuss.elastic.co/t/same-pattern-file-gives-pattern-not-define-for-only-one-pattern/134368 "2018-06-04T07:15:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SashaAlex](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@SashaAlex](https://discuss.elastic.co/u/SashaAlex)\
**Post date:** [June 4, 2018, 7:15am UTC](https://discuss.elastic.co/t/same-pattern-file-gives-pattern-not-define-for-only-one-pattern/134368/1 "2018-06-04T07:15:35Z")

</div>

I have following pattern file.  
CPAT ([\w-]+)  
FRDOM ([\w-]+)  
DEVC ([\w]+)

I had given permission for pattern file. but it gives the following error.

Pipeline aborted due to error {:exception=\>#\<Grok::PatternError: pattern %{CPAT:devicename} not defined\>

my filter is like this.  
grok{  
patterns\_dir =\> ["/etc/logstash/pattern.d"]  
match =\> { "message" =\> "%{CISCOTIMESTAMP:timestamp} %{IP:serverip}.%%{DEVC:dev}.%{DEVC:devnum}.%{DEVC:status}: Device('%{CPAT:devicename}'/'%{CPAT:device}'/%{CPAT:devicemac}. at %{FRDOM:dom}.'%{FRDOM:rfdomain}" }  
}

---

<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:** [June 4, 2018, 2:59pm UTC](https://discuss.elastic.co/t/same-pattern-file-gives-pattern-not-define-for-only-one-pattern/134368/2 "2018-06-04T14:59:16Z")

</div>

> [@SashaAlex](#):
>
> grok{  
> patterns\_dir =\> ["/etc/logstash/pattern.d"]  
> match =\> { "message" =\> "%{CISCOTIMESTAMP:timestamp} %{IP:serverip}.%%{DEVC:dev}.%{DEVC:devnum}.%{DEVC:status}: Device('%{CPAT:devicename}'/'%{CPAT:device}'/%{CPAT:devicemac}. at %{FRDOM:dom}.'%{FRDOM:rfdomain}" }  
> }

In 6.2.4, with that filter (provided you add a backslash between Device and the parenthesis) I do not get an error. Can you re-post the match line from the grok filter with 4 leading spaces like this:

```
match => { "message" => "%{CISCOTIMESTAMP:timestamp} %{IP:serverip}.%%{DEVC:dev}.%{DEVC:devnum}.%{DEVC:status}: Device\('%{CPAT:devicename}'/'%{CPAT:device}'/%{CPAT:devicemac}. at %{FRDOM:dom}.'%{FRDOM:rfdomain}" }

```

BTW, do you really want %% before the first DEVC?

---

<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 2, 2018, 2:59pm UTC](https://discuss.elastic.co/t/same-pattern-file-gives-pattern-not-define-for-only-one-pattern/134368/3 "2018-07-02T14:59:19Z")

</div>

Closed on July 2, 2018, 2:59pm UTC

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