fabric8io / fluent-plugin-kubernetes_metadata_filter

Enrich your fluentd events with Kubernetes metadata
Apache License 2.0
350 stars 166 forks source link

How to parse redis log fields with fluentd #314

Closed hichem-belhocine closed 2 years ago

hichem-belhocine commented 2 years ago

please i need to parse redis log messages with fluentd. with the the following regex expression

format regexp expression /^(?.+) (?stdout|stderr)( (?.))? (?.*)$/ time_format '%Y-%m-%dT%H:%M:%S.%N%:z' i can get this example:

2021-11-02T09:31:45.289928748+01:00 stdout F 1:C 02 Nov 2021 08:31:45.289 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 2021-11-02T09:31:45.289928748+01:00 stdout F 1:C 02 Nov 2021 08:31:45.289 # Redis version=6.2.4, bits=64, commit=00000000, modified=0, pid=1, just started 2021-11-02T09:31:45.289928748+01:00 stdout F 1:C 02 Nov 2021 08:31:45.289 # Configuration loaded 2021-11-02T09:31:45.290592569+01:00 stdout F 1:M 02 Nov 2021 08:31:45.290 monotonic clock: POSIX clock_gettime 2021-11-02T09:31:45.291801101+01:00 stdout F 1:M 02 Nov 2021 08:31:45.291 Running mode=standalone, port=6379. 2021-11-02T09:31:45.291870678+01:00 stdout F 1:M 02 Nov 2021 08:31:45.291 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 2021-11-02T09:31:45.291870678+01:00 stdout F 1:M 02 Nov 2021 08:31:45.291 # Server initialized 2021-11-02T09:31:50.488897464+01:00 stdout F 1:M 02 Nov 2021 08:31:50.488 DB loaded from append only file: 5.196 seconds 2021-11-02T09:31:50.488897464+01:00 stdout F 1:M 02 Nov 2021 08:31:50.488 Ready to accept connections

The log output for Redis 2.x will look something like this: [pid] date loglevel message https://build47.com/redis-log-format-levels/

and now i want to configure the last part "log message" ==> (1:C 02 Nov 2021 08:31:45.289 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo) to get [pid] date loglevel message in separate fields??

thank you

jcantrill commented 2 years ago

I encourage you to reach out to the fluentd community as this repo is for this plugin only that is part fo fluentd https://www.fluentd.org/community