# Grok pattern for SYSLOGPROG

**URL:** <https://discuss.elastic.co/t/grok-pattern-for-syslogprog/196515>\
**Category:** Logstash\
**Created:** [August 23, 2019, 11:50am UTC](https://discuss.elastic.co/t/grok-pattern-for-syslogprog/196515 "2019-08-23T11:50:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kragh](https://avatars.discourse-cdn.com/v4/letter/k/258eb7/32.png) [@Kragh](https://discuss.elastic.co/u/Kragh)\
**Post date:** [August 23, 2019, 11:50am UTC](https://discuss.elastic.co/t/grok-pattern-for-syslogprog/196515/1 "2019-08-23T11:50:05Z")

</div>

Hi there,

I'm currently looking into Logstash which recieves our logs from the syslog server, which recieves logs from our windows hosts (logged with NXLog, parsed as JSON).

Currently I'm having having a issue with the default syslog parser, due to the program/process ID being 0 (not positive integer). Looking into the RFC it's not saying anything about positive integers is must.

So my question is, should I just make a workaround with filter (if yes, what is the best way?), or is this a subject to posting a GitHub request for changing the default grok pattern?

Below is information about setup (new to this forum, so I doesn't know if it's get formatted correct)

Sample event:

> Aug 23 01:20:00 X.X.X.X PowerShell[0]: {"EventTime":"2019-08-23 01:20:00","Hostname"XXXX",....lots of data....}

Config sample:

> ```
> input {
> syslog {
> port => 1514
> type => "syslog"
> }
> }
> 
> output {
> stdout { codec => rubydebug { metadata => true } }
> }
> 
> ```

Original grok:  
`SYSLOGPROG %{PROG:program}(?:\[%{POSINT:pid}\])?`

Suggest grok:  
`SYSLOGPROG %{PROG:program}(?:\[%{NONNEGINT:pid}\])?`

---

<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:** [August 23, 2019, 2:49pm UTC](https://discuss.elastic.co/t/grok-pattern-for-syslogprog/196515/2 "2019-08-23T14:49:18Z")

</div>

I suggest using the grok\_pattern option on the syslog filter to replace the default "\<%{POSINT:priority}\>%{SYSLOGLINE}" to a version that includes your modified SYSLOGPROG

---

<div class="post-metadata">

**Author:** ![Kragh](https://avatars.discourse-cdn.com/v4/letter/k/258eb7/32.png) [@Kragh](https://discuss.elastic.co/u/Kragh)\
**Post date:** [August 26, 2019, 12:20pm UTC](https://discuss.elastic.co/t/grok-pattern-for-syslogprog/196515/3 "2019-08-26T12:20:59Z")

</div>

Thank you for the answer, Badger... That is also an option. Reason writing this is because when you're using type =\> syslog in input, it's automatically testing multiple formats as I've read in the documentation.

Based on your reply I've solved this with the grok\_pattern and reversed the syslog2 pattern to the following:

> grok\_pattern =\> "(?:%{SYSLOGTIMESTAMP:timestamp}|%{TIMESTAMP\_ISO8601:timestamp8601}) (?:%{SYSLOGFACILITY} )?%{SYSLOGHOST:logsource}+(?: %{PROG:program}(?:[%{NONNEGINT:pid}])?:|) %{GREEDYDATA:message}"

That's what you meant, right?

---

<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:** [August 26, 2019, 12:27pm UTC](https://discuss.elastic.co/t/grok-pattern-for-syslogprog/196515/4 "2019-08-26T12:27:50Z")

</div>

Yes, it is.

---

<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:** [September 23, 2019, 12:27pm UTC](https://discuss.elastic.co/t/grok-pattern-for-syslogprog/196515/5 "2019-09-23T12:27:52Z")

</div>

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