Fields recognition after multiline filtering in logstash -


i trying filter fields in log file groups of lines like

================================= begin of purge log =================================  inf: verification du lancement du start inf: purge du contenu du repertoire des logs archivees 15j - /users/wtp00/log/archive inf: purge du contenu du repertoire tmp 8j - /users/wtp00/tmp inf: purge du contenu du repertoire histo 8j - /users/wtp00/histo  ================================= end of purge log ================================= 

i had succeed in treating inf lines message multiline codec. following filter ...

filter {     # exclude lines no relevant data     if ([message] !~ "(^\s*inf:|^\s*$)")  {         drop {}     }     # treat consecutive lines beginning inf: group     multiline {         pattern => "^inf: "         => "previous"     }     # delete messages blank lines     if ([message] == "")  {         drop {}     }     # delete \n messages     mutate     {        gsub => ["message", "\n", ""]     }  } 

... following result ...

{        "message" => "inf: verification du lancement du startinf: purge du contenu du repertoire des logs archivees 15j - /users/wtp00/log/archiveinf: purge du contenu du repertoire tmp 8j - /users/wtp00/tmpinf: purge du contenu du repertoire histo 8j - /users/wtp00/histo",       "@version" => "1",     "@timestamp" => "2015-07-13t15:01:49.442z",           "host" => "suse",           "tags" => [         [0] "multiline"     ] } 

now in message want recognize fields (string before - , path after -) each line, easy taking in account inf: beginning of each line.

in example result of field searching message should like:

warning[0] = "verification du lancement du start" warning[1] = "purge du contenu du repertoire des logs archivees 15j" warning[2] = "purge du contenu du repertoire tmp 8j" warning[3] = "purge du contenu du repertoire histo 8j"  path[0] = "" path[1] = "/users/wtp00/log/archive" path[2] = "/users/wtp00/tmp" path[3] = "/users/wtp00/histo" 

i have been trying in different ways, , keep trying, , not know how do. appreciated.

regards.

the key make grok field recognition different matches before multiline.

the solution following one:

filter {     # exclude lines no relevant data     if ([message] !~ "(^\s*inf:|^\s*$)")  {         drop {}     }     # search warning message , path in messages     grok {         match => [ "message", "inf: %{greedydata:warning} - %{greedydata:logpath}" ]         match => [ "message", "inf: %{greedydata:warning}" ]         match => [ "message", "^\s*$" ]     }     # add empty logpath field purge message if not present     if ![logpath] {         if ([message] != "") {             mutate {                 add_field => { "logpath" => "" }             }         }     }     # treat consecutive lines beginning inf: group     multiline {         pattern => "^inf: "         => "previous"     }     # delete \n messages     if ([message] == "")  {         drop {}     }  } 

two important things:

  • do not use "path" field name
  • do not add fields empty lines, dropping them afterwards did not work

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -