File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ def register
56
56
@grok_filter = LogStash ::Filters ::Grok . new (
57
57
"overwrite" => "message" ,
58
58
"match" => { "message" => "<%{POSINT:priority}>%{SYSLOGLINE}" } ,
59
- "tag_on_failure" => [ "_grokparsefailure_sysloginputplugin " ] ,
59
+ "tag_on_failure" => [ "_grokparsefailure_sysloginput " ] ,
60
60
)
61
61
62
62
@date_filter = LogStash ::Filters ::Date . new (
@@ -198,7 +198,7 @@ def close_tcp
198
198
def syslog_relay ( event )
199
199
@grok_filter . filter ( event )
200
200
201
- if event [ "tags" ] . nil? || !event [ "tags" ] . include? ( "_grokparsefailure" )
201
+ if event [ "tags" ] . nil? || !event [ "tags" ] . include? ( @grok_filter . tag_on_failure )
202
202
# Per RFC3164, priority = (facility * 8) + severity
203
203
# = (facility << 3) & (severity)
204
204
priority = event [ "priority" ] . to_i rescue 13
Original file line number Diff line number Diff line change 1
1
# coding: utf-8
2
2
require "test_utils"
3
3
require "socket"
4
+ require "logstash/inputs/syslog"
5
+ require "logstash/event"
4
6
5
- describe "inputs/syslog" , :socket => true do
7
+ describe "inputs/syslog" do
6
8
extend LogStash ::RSpec
7
9
8
- describe " properly handles priority, severity and facilities" do
10
+ it "should properly handle priority, severity and facilities", :socket => true do
9
11
port = 5511
10
12
event_count = 10
11
13
39
41
end
40
42
end
41
43
42
- describe "adds unique tag when grok parsing fails" do
44
+ it "should add unique tag when grok parsing fails with live syslog input" , :socket => true do
43
45
port = 5511
44
46
event_count = 10
45
47
70
72
end
71
73
end
72
74
end
75
+
76
+ it "should add unique tag when grok parsing fails" do
77
+ input = LogStash ::Inputs ::Syslog . new ( { } )
78
+ input . register
79
+
80
+ # event which is not syslog should have a new tag
81
+ event = LogStash ::Event . new ( { "message" => "hello world, this is not syslog RFC3164" } )
82
+ input . syslog_relay ( event )
83
+ insist { event [ "tags" ] } == [ "_grokparsefailure_sysloginput" ]
84
+
85
+ syslog_event = LogStash ::Event . new ( { "message" => "<164>Oct 26 15:19:25 1.2.3.4 %ASA-4-106023: Deny udp src DRAC:10.1.2.3/43434" } )
86
+ input . syslog_relay ( syslog_event )
87
+ insist { syslog_event [ "priority" ] } == 164
88
+ insist { syslog_event [ "severity" ] } == 4
89
+ insist { syslog_event [ "tags" ] } == nil
90
+ end
91
+
73
92
end
You can’t perform that action at this time.
0 commit comments