Hello,
I'm not getting the desired output for this example that I"m testing on my windows machine.
file: sqllog
INFO - 12345 - TASK_START - start
INFO - 12345 - SQL - sqlQuery1 - 12
INFO - 12345 - SQL - sqlQuery2 - 34
INFO - 12345 - TASK_END - end
file: logstash-sql.conf
input {
file {
path => "C:\logstash\sqllog"
start_position => beginning
}
}
filter {
grok {
match => [ "message", "%{LOGLEVEL:loglevel} - %{NOTSPACE:taskid} - %{NOTSPACE:logger} - %{WORD:label}( - %{INT:duration:int})?" ]
}
if [logger] == "TASK_START" {
aggregate {
task_id => "%{taskid}"
code => "map['sql_duration'] = 0"
map_action => "create"
}
}
if [logger] == "SQL" {
aggregate {
task_id => "%{taskid}"
code => "map['sql_duration'] += event['duration']"
map_action => "update"
}
}
if [logger] == "TASK_END" {
aggregate {
task_id => "%{taskid}"
code => "event['sql_duration'] = map['sql_duration']"
map_action => "update"
end_of_task => true
timeout => 120
}
}
}
output {
stdout {}
}
Running Logstash:
>logstash.bat -f C:\logstash\logstash-sql.conf -w 1
Settings: User set pipeline workers: 1, Default pipeline workers: 4
Pipeline main started
2016-08-03T09:56:50.382Z PGGV999 INFO - 12345 - TASK_START - start
2016-08-03T09:56:50.569Z PGGV999 INFO - 12345 - SQL - sqlQuery1 - 12
2016-08-03T09:56:50.570Z PGGV999 INFO - 12345 - SQL - sqlQuery2 - 34
The pipeline ends here, but I'm expecting:
{
"message" => "INFO - 12345 - TASK_END - end",
"sql_duration" => 46
}
Can someone help what I'm doing wrong here?
Thanks.