# Grok parsing syslog error

**URL:** <https://discuss.elastic.co/t/grok-parsing-syslog-error/142748>\
**Category:** Logstash\
**Created:** [August 2, 2018, 11:00am UTC](https://discuss.elastic.co/t/grok-parsing-syslog-error/142748 "2018-08-02T11:00:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielE](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@DanielE](https://discuss.elastic.co/u/DanielE)\
**Post date:** [August 2, 2018, 11:00am UTC](https://discuss.elastic.co/t/grok-parsing-syslog-error/142748/1 "2018-08-02T11:00:05Z")

</div>

Hey there,  
i am trying to gather my syslog infos parse them trough a grok filter. But i am getting \_grokparsefailure\_sysloginput and \_grokparsefailure. I am using the following configs:

input

```
input {
  syslog {
      port => 5000
      syslog_field => "syslog"
      grok_pattern => "<%{POSINT:syslog_pri}> %{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:host} %{POSINT:syslog_pid} %{DATA:syslog_program}: %{GREEDYDATA:syslog_message}"
      tags => "syslog"
      add_field => {
          "origin" => "syslog"
      }
  }
}

```

filter

```
filter {
  if [origin] == "syslog" {
      grok {
            match => { "message" => "<%{POSINT:syslog_pri}> %{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:host} %{POSINT:syslog_pid} %{DATA:syslog_program}: %{GREEDYDATA:syslog_message}" }
            add_field => ["received_at", "%{@timestamp}"]
            add_field => ["received_from", "%{host}"]
      }
      mutate {
         add_field => {
            retention => "medium"
         }
      }
  }
}

```

A Syslog message looks something like this:

\<14\> Jan 2 01:01:05 10.121.116.8 00828 lldp: PVID mismatch on port 1(VID 100)with peer device port 37(VID 2)(2887)

---

<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:** [August 2, 2018, 11:31am UTC](https://discuss.elastic.co/t/grok-parsing-syslog-error/142748/2 "2018-08-02T11:31:19Z")

</div>

Surely you don't need both the syslog input **and** a grok filter? I can't immediately spot any problems with the grok expression in the syslog input. Start simple with `^<%{POSINT:syslog_pri}>`and verify that that works, then continue to add more and more to the expression until things break.

---

<div class="post-metadata">

**Author:** ![DanielE](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@DanielE](https://discuss.elastic.co/u/DanielE)\
**Post date:** [August 2, 2018, 11:45am UTC](https://discuss.elastic.co/t/grok-parsing-syslog-error/142748/3 "2018-08-02T11:45:17Z")

</div>

i removed the grok pattern in the filter conf. Now i only have a small grok in the input conf

```
input {
  syslog {
      port => 5000
      syslog_field => "syslog"
      grok_pattern => "<%{POSINT:syslog_pri}>"
      tags => "syslog"
      add_field => {
          "origin" => "syslog"
      }
  }
}

```

Now i´m only getting \_grokparsefailure\_sysloginput but still no syslog\_pri in my log.

---

<div class="post-metadata">

**Author:** ![DanielE](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@DanielE](https://discuss.elastic.co/u/DanielE)\
**Post date:** [August 2, 2018, 1:48pm UTC](https://discuss.elastic.co/t/grok-parsing-syslog-error/142748/4 "2018-08-02T13:48:26Z")

</div>

It now works. I removed the grok\_pattern and used a grok in the filter config. But i am still getting the \_grokparsefailure\_sysloginput. I will probably remove it in the filter. For documentation reasons my running input and filter.

```
input {
  syslog {
      port => 5000
      syslog_field => "syslog"
      tags => "syslog"
      add_field => {
          "origin" => "syslog"
      }
  }
}

filter {
  if [origin] == "syslog" {
      grok {
        match => { "message" => "<%{POSINT:syslog_pri}> %{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:host} %{NUMBER:syslog_pid} %{DATA:syslog_program}: %{GREEDYDATA:syslog_message}"}
      }
      mutate {
         add_field => {
            retention => "medium"
         }
         remove_tag => ["_grokparsefailure_sysloginput"]
      }
  }
}
```

---

<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:** [August 30, 2018, 1:48pm UTC](https://discuss.elastic.co/t/grok-parsing-syslog-error/142748/5 "2018-08-30T13:48:29Z")

</div>

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