logstash grok filter for logs with arbitrary attribute-value pairs -
(this related other question logstash grok filter custom logs )
i have logfile lines like:
14:46:16.603 [http-nio-8080-exec-4] info metering - msg=93e6dd5e-c009-46b3-b9eb-f753ee3b889a create_job job=a820018e-7ad7-481a-97b0-bd705c3280ad data=71b1652e-16c8-4b33-9a57-f5fcb3d5de92 14:46:17.378 [http-nio-8080-exec-3] info metering - msg=c1ddb068-e6a2-450a-9f8b-7cbc1dbc222a set_status job=a820018e-7ad7-481a-97b0-bd705c3280ad status=active final=false
i built pattern matched first line:
%{time:timestamp} %{notspace:http} %{word:loglevel}%{space}%{word:logtype} - msg=%{notspace:msg}%{space}%{word:action}%{space}job=%{notspace:job}%{space}data=%{notspace:data}
but works lines have data=
@ end, versus status=
, final=
@ end of second line, or other attribute-value pairs on other lines? how can set pattern says after point there arbitrary of foo=bar
pairs want recognize , output attribute/value pairs in output?
you can change grok pattern have key value pairs in 1 field (kvpairs
):
%{time:timestamp} %{notspace:http} %{word:loglevel}%{space}%{word:logtype} - %{greedydata:kvpairs}
afterwards can use kv filter parse key value pairs.
kv { source => "kvpairs" remove_field => [ "kvpairs" ] # delete field afterwards }
unfortunately, have simple values inside kv pairs (e.g. create_job
). parse them grok , use 1 kv filter values before , kv filter values after simple values.
Comments
Post a Comment