mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
add unique tag for grok parser in module input
This commit is contained in:
parent
6b20d179aa
commit
bdd69065a4
2 changed files with 35 additions and 1 deletions
|
@ -56,6 +56,7 @@ class LogStash::Inputs::Syslog < LogStash::Inputs::Base
|
||||||
@grok_filter = LogStash::Filters::Grok.new(
|
@grok_filter = LogStash::Filters::Grok.new(
|
||||||
"overwrite" => "message",
|
"overwrite" => "message",
|
||||||
"match" => { "message" => "<%{POSINT:priority}>%{SYSLOGLINE}" },
|
"match" => { "message" => "<%{POSINT:priority}>%{SYSLOGLINE}" },
|
||||||
|
"tag_on_failure" => ["_grokparsefailure_sysloginputplugin"],
|
||||||
)
|
)
|
||||||
|
|
||||||
@date_filter = LogStash::Filters::Date.new(
|
@date_filter = LogStash::Filters::Date.new(
|
||||||
|
|
|
@ -29,6 +29,8 @@ describe "inputs/syslog", :socket => true do
|
||||||
socket.close
|
socket.close
|
||||||
|
|
||||||
events = event_count.times.collect { queue.pop }
|
events = event_count.times.collect { queue.pop }
|
||||||
|
|
||||||
|
insist { events.length } == event_count
|
||||||
event_count.times do |i|
|
event_count.times do |i|
|
||||||
insist { events[i]["priority"] } == 164
|
insist { events[i]["priority"] } == 164
|
||||||
insist { events[i]["severity"] } == 4
|
insist { events[i]["severity"] } == 4
|
||||||
|
@ -36,5 +38,36 @@ describe "inputs/syslog", :socket => true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
describe "adds unique tag when grok parsing fails" do
|
||||||
|
port = 5511
|
||||||
|
event_count = 10
|
||||||
|
|
||||||
|
config <<-CONFIG
|
||||||
|
input {
|
||||||
|
syslog {
|
||||||
|
type => "blah"
|
||||||
|
port => #{port}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CONFIG
|
||||||
|
|
||||||
|
input do |pipeline, queue|
|
||||||
|
Thread.new { pipeline.run }
|
||||||
|
sleep 0.1 while !pipeline.ready?
|
||||||
|
|
||||||
|
socket = Stud.try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
||||||
|
event_count.times do |i|
|
||||||
|
socket.puts("message which causes the a grok parse failure")
|
||||||
|
end
|
||||||
|
socket.close
|
||||||
|
|
||||||
|
events = event_count.times.collect { queue.pop }
|
||||||
|
|
||||||
|
insist { events.length } == event_count
|
||||||
|
event_count.times do |i|
|
||||||
|
insist { events[i]["tags"] } == ["_grokparsefailure_sysloginputplugin"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue