I have a pattern that the Grok Debugger in Kibana says works. Testing gives me the output I expect. However when run in Logstash I get a failure.
Here is the log message I am trying to parse:
DEBUG: 12/17/18 00:01:42.696 PID=4310 (cbaldslTL1d 1000 25100)\nMonitorNbr:40070768 WorkNbr:5867 Op:RFRSH_PHONE DirNum:7702423620 DevId: SubId:500001-123456\nTL1Client::TL1Client(), HOST=127.0.0.1/127.0.0.1\n"
Here is my filter configuration, it should be matching on Triad Format 2
filter {
mutate {
gsub => [
# Replace the line of dashes
"message", "-+$", ""
]
}
# Handle Vision360 Logs
if [fields][log_type] == "vision360"{
grok {
match => {
"message" => "%{DATE_US} %{TIME} %{WORD:log_level}"
}
}
} else if [fields][log_type] == "triad-current-msg" {
#
# Triad Log Format 1
#
grok {
match => {
"message" => "%{WORD:log_level}: %{DATE_US}.* %{TIME}.* %{WORD}.*=%{NUMBER:pid} \(%{WORD:process_name} %{NUMBER:controller_number} %{NUMBER:instance_number}"
}
}
#
# Triad Log Format 2
#
grok {
match => {
"message" => "%{WORD:log_level}: %{DATESTAMP} PID=%{NUMBER:pid} \(%{WORD:process_name} %{NUMBER:controller_number} %{NUMBER:instance_number}\)\\nMonitorNbr:%{NUMBER:monitor_number} WorkNbr:%{NUMBER:work_number} Op:%{WORD:operation} DirNum:%{NUMBER:directory_number} DevId:(%{WORD:device_id})? SubId:%{WORD:subscriber_id}"
}
}
}
}
Here is the input message from the Logstash log
[2018-12-20T13:07:46,927][DEBUG][logstash.pipeline ] filter received {"event"=>{"tags"=>["beats_input_codec_plain_applied"], "host"=>{"architecture"=>"x86_64", "os"=>{"family"=>"redhat", "platform"=>"cent
os", "codename"=>"Final", "version"=>"6.10 (Final)"}, "containerized"=>true, "name"=>"yellow"}, "offset"=>1829, "log"=>{"flags"=>["multiline"]}, "prospector"=>{"type"=>"log"}, "source"=>"/home/eti/logtest/triad-
current-msg-format.log", "@timestamp"=>2018-12-20T18:08:02.913Z, "input"=>{"type"=>"log"}, "fields"=>{"log_type"=>"triad-current-msg"}, "beat"=>{"version"=>"6.5.3", "name"=>"yellow470.dev.etisoftware.local", "ho
stname"=>"yellow"}, "message"=>"DEBUG: 12/17/18 00:01:42.696 PID=4310 (cbaldslTL1d 1000 25100)\nMonitorNbr:40070768 WorkNbr:5867 Op:RFRSH_PHONE DirNum:7702423620 DevId: SubId:500001-123456\nTL1Client::TL1Client(
), HOST=127.0.0.1/127.0.0.1\n------------------------------------------------------------------------------", "@version"=>"1"}}
Here is the output message:
[2018-12-20T13:07:46,941][DEBUG][logstash.pipeline ] output received {"event"=>{"tags"=>["beats_input_codec_plain_applied", "_grokparsefailure"], "host"=>{"architecture"=>"x86_64", "os"=>{"family"=>"redha
t", "platform"=>"centos", "codename"=>"Final", "version"=>"6.10 (Final)"}, "containerized"=>true, "name"=>"yellow"}, "offset"=>1829, "log"=>{"flags"=>["multiline"]}, "instance_number"=>"25100", "prospector"=>{"t
ype"=>"log"}, "pid"=>"4310", "log_level"=>"DEBUG", "source"=>"/home/eti/logtest/triad-current-msg-format.log", "@timestamp"=>2018-12-20T18:08:02.913Z, "process_name"=>"cbaldslTL1d", "controller_number"=>"1000",
"input"=>{"type"=>"log"}, "fields"=>{"log_type"=>"triad-current-msg"}, "beat"=>{"version"=>"6.5.3", "name"=>"yellow470.dev.etisoftware.local", "hostname"=>"yellow"}, "message"=>"DEBUG: 12/17/18 00:01:42.696 PID=
4310 (cbaldslTL1d 1000 25100)\nMonitorNbr:40070768 WorkNbr:5867 Op:RFRSH_PHONE DirNum:7702423620 DevId: SubId:500001-123456\nTL1Client::TL1Client(), HOST=127.0.0.1/127.0.0.1\n", "@version"=>"1"}}
If I used the Kibana Debugger I get this as my output:
{
"instance_number": "25100",
"log_level": "DEBUG",
"pid": "4310",
"monitor_number": "40070768",
"controller_number": "1000",
"work_number": "5867",
"directory_number": "7702423620",
"subscriber_id": "500001",
"process_name": "cbaldslTL1d",
"operation": "RFRSH_PHONE"
}
I have tried reversing the order of the Grok definitions but I get the same result.