Closed vDMG closed 3 years ago
Hmm, I could repro this by using $impersonatedUser and the same regex. I'm wondering if this is failing because there are no fields for $impersonatedUser only a nest JSON. @nokute78 anything come to mind?
When I used the following grep filter it works as intended:
[FILTER]
name grep
match log
regex $impersonatedUser['username'] .*
@vDMG Could you test @agup006 's configuration ? I confirmed that fluent-bit outputted what you expected.
It is
[SERVICE]
Flush 1
Daemon off
Log_Level debug
Parsers_File parsers.conf
[INPUT]
name tail
path a.log
Read_From_Head on
Parser json
[FILTER]
name grep
match *
regex $impersonatedUser['username'] .+
[OUTPUT]
name stdout
match **
@agup006 Hmm, I have no idea...
The difference is come from the return value of subkey_to_object
which is changed with record accessor or not.
https://github.com/fluent/fluent-bit/blob/86f215a98250088189118547147ed1f2597a9b93/src/flb_ra_key.c#L344-L347
Thanks @agup006 and @nokute78 I'll go with
regex $impersonatedUser['username'] .+
It works :smile:
Bug Report
Issue with Grep Filter on complex JSON structure
I'm trying to filter logs from a file using the grep filter, I want fluent-bit to output only logs which contains the
impersonatedUser
keyTo Reproduce
config-file:
log examples:
Expected behavior
Fluent-bit should output logs containing the field
impersonatedUser
Your Environment
Additional context
I've tried a lot of different config and settings to try to solve this, like using recordaccessor with
$impersonatedUser
or trying removing the upper case but impossible to make this works