Vlad Vintila
2012-05-07 15:20:54 UTC
Hello,
I'm not sure if this can be done, and I admit that it's a strange request
to have, but here it goes.
I'm trying to make a grok filter that parses a python dict that has a
variable number of keys.
So if I have:
{ 'key1': 'value1', 'key2': 'value2' , 'key3': 'value3'} I would like grok
to add 3 fields with the key names as the field name, and their respecting
values.
Something like this:
grok{
type => "mylog"
pattern => "'%{STRING:type}': '%{DATA:value}'"
add_field => ["%{type}","%{value}"]
}
This doesn't work ofc, as it would only match once, also the %{type} does
not get replaced with its value(as opposed to %{value}), and removing the
quotes results in syntax error.
The alternative to this is to have each key(they are many, but finite)
defined in my patterns file, but I am hoping you guys will show me the
smart way.
Thanks,
Vlad Vintila
I'm not sure if this can be done, and I admit that it's a strange request
to have, but here it goes.
I'm trying to make a grok filter that parses a python dict that has a
variable number of keys.
So if I have:
{ 'key1': 'value1', 'key2': 'value2' , 'key3': 'value3'} I would like grok
to add 3 fields with the key names as the field name, and their respecting
values.
Something like this:
grok{
type => "mylog"
pattern => "'%{STRING:type}': '%{DATA:value}'"
add_field => ["%{type}","%{value}"]
}
This doesn't work ofc, as it would only match once, also the %{type} does
not get replaced with its value(as opposed to %{value}), and removing the
quotes results in syntax error.
The alternative to this is to have each key(they are many, but finite)
defined in my patterns file, but I am hoping you guys will show me the
smart way.
Thanks,
Vlad Vintila