Skip to content

Commit

Permalink
Merge pull request elastic#791 from pdf/LOGSTASH-1630
Browse files Browse the repository at this point in the history
[LOGSTASH-1630] Syslog 5424 patterns fail to match additional spaces
  • Loading branch information
jordansissel committed Nov 22, 2013
2 parents 26e9bb2 + 01737e0 commit a1bca67
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion patterns/linux-syslog
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ SYSLOGLINE %{SYSLOGBASE2} %{GREEDYDATA:message}
# IETF 5424 syslog(8) format (see http://www.rfc-editor.org/info/rfc5424)
SYSLOG5424PRI <%{NONNEGINT:syslog5424_pri}>
SYSLOG5424SD \[%{DATA}\]+
SYSLOG5424BASE %{SYSLOG5424PRI}%{NONNEGINT:syslog5424_ver} +(?:%{TIMESTAMP_ISO8601:syslog5424_ts}|-) +(?:%{HOSTNAME:syslog5424_host}|-) +(?:%{WORD:syslog5424_app}|-) +(?:%{WORD:syslog5424_proc}|-) +(?:%{WORD:syslog5424_msgid}|-) +(?:%{SYSLOG5424SD:syslog5424_sd}|-|)

SYSLOG5424LINE %{SYSLOG5424PRI}%{NONNEGINT:syslog5424_ver} (?:%{TIMESTAMP_ISO8601:syslog5424_ts}|-) (?:%{HOSTNAME:syslog5424_host}|-) (?:%{WORD:syslog5424_app}|-) (?:%{WORD:syslog5424_proc}|-) (?:%{WORD:syslog5424_msgid}|-) (?:%{SYSLOG5424SD:syslog5424_sd}|-) %{GREEDYDATA:syslog5424_msg}
SYSLOG5424LINE %{SYSLOG5424BASE} +%{GREEDYDATA:syslog5424_msg}
39 changes: 39 additions & 0 deletions spec/filters/grok.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,45 @@
insist { subject["syslog5424_sd"] } == nil
insist { subject["syslog5424_msg"] } == "No PID or SD."
end

sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug 4123 - Missing structured data." do
insist { subject["tags"] }.nil?
insist { subject["syslog5424_pri"] } == "191"
insist { subject["syslog5424_ver"] } == "1"
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
insist { subject["syslog5424_host"] } == "paxton.local"
insist { subject["syslog5424_app"] } == "grokdebug"
insist { subject["syslog5424_proc"] } == "4123"
insist { subject["syslog5424_msgid"] } == nil
insist { subject["syslog5424_sd"] } == nil
insist { subject["syslog5424_msg"] } == "Missing structured data."
end

sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug 4123 - - Additional spaces." do
insist { subject["tags"] }.nil?
insist { subject["syslog5424_pri"] } == "191"
insist { subject["syslog5424_ver"] } == "1"
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
insist { subject["syslog5424_host"] } == "paxton.local"
insist { subject["syslog5424_app"] } == "grokdebug"
insist { subject["syslog5424_proc"] } == "4123"
insist { subject["syslog5424_msgid"] } == nil
insist { subject["syslog5424_sd"] } == nil
insist { subject["syslog5424_msg"] } == "Additional spaces."
end

sample "<191>1 2009-06-30T18:30:00+02:00 paxton.local grokdebug 4123 - Additional spaces and missing SD." do
insist { subject["tags"] }.nil?
insist { subject["syslog5424_pri"] } == "191"
insist { subject["syslog5424_ver"] } == "1"
insist { subject["syslog5424_ts"] } == "2009-06-30T18:30:00+02:00"
insist { subject["syslog5424_host"] } == "paxton.local"
insist { subject["syslog5424_app"] } == "grokdebug"
insist { subject["syslog5424_proc"] } == "4123"
insist { subject["syslog5424_msgid"] } == nil
insist { subject["syslog5424_sd"] } == nil
insist { subject["syslog5424_msg"] } == "Additional spaces and missing SD."
end
end

describe "parsing an event with multiple messages (array of strings)", :if => false do
Expand Down

0 comments on commit a1bca67

Please sign in to comment.