# Pattern not defined

**URL:** <https://discuss.elastic.co/t/pattern-not-defined/299893>\
**Category:** Logstash\
**Created:** [March 16, 2022, 7:04pm UTC](https://discuss.elastic.co/t/pattern-not-defined/299893 "2022-03-16T19:04:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guif](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guif/32/103032_2.png) [@Guif](https://discuss.elastic.co/u/Guif)\
**Post date:** [March 16, 2022, 7:04pm UTC](https://discuss.elastic.co/t/pattern-not-defined/299893/1 "2022-03-16T19:04:42Z")

</div>

Hi,

I try to ingest the logs /var/log/maillog with the following pattern via logstash:

```auto
POSTFIX_QUEUEID ([0-9A-F]{6,}|[0-9a-zA-Z]{15,})
POSTFIX_STATUS (?<=status=)(.*)(?= \()
POSTFIX_PROCESS (?=postfix\/)(.*?\[)(.*?)(?=: )
POSTFIX_TO (?<=to=<)(.*?)(?=>,)
POSTFIX_RELAY (?<=relay=)(.*?)(?=,)
POSTFIX_SUBJECT (?<=Subject: )(.*)(?= from )

SMTP ^%{SYSLOGTIMESTAMP:timestamp}%{SPACE}%{DATA:hostname}%{SPACE}%{POSTFIX_PROCESS:process}%{GREEDYDATA}%{POSTFIX_QUEUEID:queueid}%{GREEDYDATA}%{POSTFIX_TO:to}%{GREEDYDATA}%{POSTFIX_RELAY:relay}%{GREEDYDATA}%{POSTFIX_STATUS:status}%{SPACE}%{GREEDYDATA:response}
CLEANUP ^%{SYSLOGTIMESTAMP:timestamp}%{SPACE}%{DATA:hostname}%{SPACE}%{POSTFIX_PROCESS:process}:%{SPACE}%{POSTFIX_QUEUEID:queueid}%{GREEDYDATA}%{POSTFIX_SUBJECT:subject}%{GREEDYDATA:something2}

```

But appears an error (_pattern %{SUBJECT} not defined\>_)

```auto
Pipeline error {:pipeline_id=>"main", :exception=>#<Grok::PatternError: pattern %{SUBJECT} not defined>, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/jls-grok-0.11.5/lib/grok-pure.rb:123:in `block in compile'"

```

Content of logstash.conf:

```auto
input {
  file {
    path => "/var/log/maillog"
    exclude => "*.gz"
    start_position => "beginning"
    type => "postfix"
  }
}

filter {
  grok {
    patterns_dir => ["/etc/logstash/conf.d/patterns"]
    match => { "message" => ["%{SMTP}", "%{SUBJECT}", "%{CONNECTION}"] }
  }

```

What's exactly wrong on the pattern? How can I solve this?

Thanks in advance.

---

<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:** [March 16, 2022, 7:48pm UTC](https://discuss.elastic.co/t/pattern-not-defined/299893/2 "2022-03-16T19:48:30Z")

</div>

> [@Guif](#):
>
> pattern %{SUBJECT} not defined\>

You have defined a POSTFIX\_SUBJECT pattern, but not a SUBJECT pattern, so it is not defined...

---

<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:** [April 13, 2022, 7:49pm UTC](https://discuss.elastic.co/t/pattern-not-defined/299893/3 "2022-04-13T19:49:07Z")

</div>

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