I am trying to write a regular expression of the logstash grok filter for the log of my web application. The format log itself:
2015-12-02 14:5728,763 POST 1.1.1.1 627472 start_one windows 7 x64 Decryption:
Date method address number function system
I can handle the "normal" log
%{TIMESTAMP_ISO8601:date} %{WORD:method} %{IPV4:client} %{NUMBER:size} %{WORD:def} (?<VerOs>.*) At the exit we have
{ "date": [ "2015-12-02 14:5728,763" ], "method": [ "POST" ], "client": [ "1.1.1.1" ], "size": [ "627472" ], "def": [ "start_one" ], "VerOs": [ "windows 7 x64" ] } But with a log in which there is an error or an empty variable, I can not
error log:
2015-12-3 12:16:43,631 POST 2.2.2.2 637263 error=Bad request - 2015-12-3 12:16:43,631 POST 2.2.2.2 error=No found this address - - 2015-12-3 12:16:46,631 GET - - - 2015-12-3 12:16:46,631 POST 3.3.3.3 del - I would like to change the names of variables in the field where an error occurred on error and exclude empty fields (indicated by the "-" symbol) from filtering
I want to get something like this. I can change the logging in the system
{ "date": [ "2015-12-02 14:5728,763" ], "method": [ "POST" ], "client": [ "1.1.1.1" ], "size": [ "627472" ], "error": [ "Bad request" ] }