Hello,
I'm trying to use logstash 1.5.1 to parse an application log file with the following pattern:
2015-04-30 17:11:04.640 [INFO] 123 message started
2015-04-30 17:11:14.320 [DEBUG] 123 message in the middle
2015-04-30 17:11:14.850 [INFO] 124 message started
2015-04-30 17:11:15.240 [INFO] 123 message ended
2015-04-30 17:11:18.340 [DEBUG] 124 message in the middle
2015-04-30 17:11:19.620 [INFO] 124 message ended
2015-04-30 17:11:24.640 [INFO] 230 message started
2015-04-30 17:11:29.620 [INFO] 230 message ended
2015-04-30 17:11:39.220 [INFO] 450 message started
2015-04-30 17:11:51.420 [INFO] 455 message started
2015-04-30 17:11:53.420 [DEBUG] 455 message in the middle
2015-04-30 17:11:53.456 [DEBUG] 450 message in the middle
2015-04-30 17:11:54.431 [INFO] 455 message ended
2015-04-30 17:11:56.431 [INFO] 450 message ended
At the end I need to generate an output file with time difference between "message started" and "message ended" for each thread id.
I'm not a logstash expert and after some hard work I realize that I need your support. I created the following configuration file but it doesn't work:
input {
file {
path => "/home/vagrant/workdir/temp.log"
start_position => beginning
}
}
filter {
grok {
match => [ "message" , "''%{TIMESTAMP_ISO8601:logdate} %{LOGLEVEL:loglevel} [%{DATA:thread}] message started" ]
add_tag => [ "transactionstarted" ]
}
grok {
match => [ "message" , "''%{TIMESTAMP_ISO8601:logdate} %{LOGLEVEL:loglevel} [%{DATA:thread}] message ended" ]
add_tag => [ "transactionended" ]
}
elapsed
{
start_tag => "transactionstarted"
end_tag => "transactionended"
unique_id_field => "thread"
}
}
output {
file {
path => "/home/vagrant/workdir/output.log"
}
}
Wrong output generated:
{"message":"2015-04-30 17:11:04.640 [INFO] 123\tmessage started ","@version":"1","@timestamp":"2015-06-18T00:21:30.224Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:14.320 [DEBUG] 123\tmessage in the middle ","@version":"1","@timestamp":"2015-06-18T00:21:30.232Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:14.850 [INFO] 124\tmessage started ","@version":"1","@timestamp":"2015-06-18T00:21:30.237Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:15.240 [INFO] 123\tmessage ended ","@version":"1","@timestamp":"2015-06-18T00:21:30.243Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:18.340 [DEBUG] 124\tmessage in the middle","@version":"1","@timestamp":"2015-06-18T00:21:30.256Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:19.620 [INFO] 124\tmessage ended","@version":"1","@timestamp":"2015-06-18T00:21:30.271Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:24.640 [INFO] 230\tmessage started ","@version":"1","@timestamp":"2015-06-18T00:21:30.284Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:29.620 [INFO] 230\tmessage ended","@version":"1","@timestamp":"2015-06-18T00:21:30.291Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:39.220 [INFO] 450\tmessage started","@version":"1","@timestamp":"2015-06-18T00:21:30.303Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:51.420 [INFO] 455\tmessage started","@version":"1","@timestamp":"2015-06-18T00:21:30.312Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:53.420 [DEBUG] 455\tmessage in the middle","@version":"1","@timestamp":"2015-06-18T00:21:30.314Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:53.456 [DEBUG] 450\tmessage in the middle","@version":"1","@timestamp":"2015-06-18T00:21:30.335Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:54.431 [INFO] 455\tmessage ended","@version":"1","@timestamp":"2015-06-18T00:21:30.360Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
{"message":"2015-04-30 17:11:56.431 [INFO] 450\tmessage ended","@version":"1","@timestamp":"2015-06-18T00:21:30.388Z","host":"0.0.0.0","path":"/home/vagrant/workdir/temp.log","tags":["_grokparsefailure"]}
Can I ask for your expertise to get the expected output?
Thanks a lot