Sojo
Sojo

Reputation: 6183

Parsing error "_grokparsefailure" in LogStash

At first I displayed the logs in Kibana from the syslog and it worked fine. I set it up according to the documentation.

Now I've changed the source of the logs, now it retrieves logs from my web application and although Kibana still displays them kind of correctly, now there're the Tags "_grokparsefailure" which means that there's an error in parsing the logs.

The current filter I have:

filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => [ "received_at", "%{@timestamp}" ]
      add_field => [ "received_from", "%{host}" ]
    }
    syslog_pri { }
    date {
      match => [ "syslog_timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]
    }
  }
}

How can I find out where the parsing error is? Is there an online service which would help me create a grok pattern for my new logs? Any other advice?

UPDATE: the logs are in json.

Upvotes: 1

Views: 2863

Answers (2)

sergpank
sergpank

Reputation: 988

You can debug your logs in Kibana

GoTo: Kibana -> Managenement -> Dev Tools -> Grok Debuggergrok debugger in kibana v 7.8.0

Upvotes: 0

Will Barnwell
Will Barnwell

Reputation: 4089

In response to OP's:

Is there an online service which would help me create a grok pattern for my new logs?

My favorite tool for testing grok patterns is: http://grokconstructor.appspot.com/do/match

But I know some prefer: https://grokdebug.herokuapp.com/

Your logs probably aren't parsing properly because you're using the syslog pattern on logs that aren't in the syslog format.

EDIT: For json log parsing you may want to look at either the json filter or the json codec

Upvotes: 2

Related Questions