fluentd
fluentd copied to clipboard
[Question] Is it have a way to reformat log in fluentd.conf?
Hi all,
This is not a bug.
Here is my log format
2018-12-11 18:07:54.573 [25][INF] [Info]{"Message":"Initialize ProfileStore Start","$type":"InfoDetail"}
Then I can use below regexp to extract logdate, thread, type1, type2 and message
/^(?<logdate>[^ ]* [^ ]*) \[(?<thread>[\d]+)\]\[(?<type1>[A-Za-z_][A-Za-z0-9_]*)\] \[(?<type2>[A-Za-z_][A-Za-z0-9_]*)\]\{(?<message>[^\}]*)/
Is it has a way that I can inject logdate, thread, type1, type2 data to message as json?
Cause after that, I push the log to elasticsearch I can get dynamic Available fields in kibana.
Thanks.
Following example will help you:
<source>
@type dummy
dummy [
{"log": "2018-12-11 18:07:54.573 [25][INF] [Info]{\"Message\":\"Initialize ProfileStore Start\",\"$type\":\"InfoDetail\"}"}
]
tag dummy
</source>
<filter dummy>
@type parser
key_name log
<parse>
@type regexp
expression /^(?<logdate>[^ ]* [^ ]*) \[(?<thread>[\d]+)\]\[(?<type1>[A-Za-z_][A-Za-z0-9_]*)\] \[(?<type2>[A-Za-z_][A-Za-z0-9_]*)\](?<message>\{[^\}]*\})/
</parse>
</filter>
<filter dummy>
@type parser
key_name message
reserve_data true
remove_key_name_field true
<parse>
@type json
</parse>
</filter>
<match dummy>
@type stdout
</match>
BTW, this issue does not follow The guideline. Closing
Hi @okkez Thanks for your reply, It's really work for me. :)