Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter_nest: Lift warning log switch #9703

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

drbugfinder-work
Copy link
Contributor

@drbugfinder-work drbugfinder-work commented Dec 10, 2024

This PR introduces a configuration parameter called suppress_warnings, which will mute warnings about lift-errors, in case the user wants to. This can be helpful in cases like different log formats (with equally named keys inside) with the same tag. The feature is disabled by default.

This PR furthermore adds the tag to the log messages to find the log source (helpful in case the filter matches multiple tags)

Fixes #7797 , Fixes #1707

Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • [N/A] Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

In case of lift, if there's no valid/matching key found and the
content cannot be lifted, the filter  will throw an error. However, there
can be scenarios, where it is intended that sometimes the lift filter does
not find a match (like two different kinds of logs with the same tag).
Then these warnings should be disableable by the user. This commit adds an
option to suppress these kind of warnings.

Signed-off-by: Richard Treu <[email protected]>
@drbugfinder-work
Copy link
Contributor Author

fluent-bit.conf

[SERVICE]
    Log_level info
[INPUT]
    Name mem
    Tag  mem.local

[FILTER]
    Name nest
    Match *
    Operation lift
    Nested_under Mem.free
    suppress_warnings true

[OUTPUT]
    Name  stdout
    Match *

@drbugfinder-work
Copy link
Contributor Author

Debug Output

Fluent Bit v3.2.3
* Copyright (C) 2015-2024 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____ 
|  ___| |                | |   | ___ (_) |         |____ |/ __  \
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   __   / /`' / /'
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \  / /  
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V /.___/ /./ /___
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)_____/


[2024/12/10 11:22:29] [ info] [fluent bit] version=3.2.3, commit=4ad29e201c, pid=133884
[2024/12/10 11:22:29] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/12/10 11:22:29] [ info] [simd    ] disabled
[2024/12/10 11:22:29] [ info] [cmetrics] version=0.9.9
[2024/12/10 11:22:29] [ info] [ctraces ] version=0.5.7
[2024/12/10 11:22:29] [ info] [input:mem:mem.0] initializing
[2024/12/10 11:22:29] [ info] [input:mem:mem.0] storage_strategy='memory' (memory only)
[2024/12/10 11:22:29] [ info] [sp] stream processor started
[2024/12/10 11:22:29] [ info] [output:stdout:stdout.0] worker #0 started
[0] mem.local: [[1733829750.282926219, {}], {"Mem.total"=>16367268, "Mem.used"=>4856220, "Mem.free"=>11511048, "Swap.total"=>4194300, "Swap.used"=>0, "Swap.free"=>4194300}]
[0] mem.local: [[1733829751.282883662, {}], {"Mem.total"=>16367268, "Mem.used"=>4856048, "Mem.free"=>11511220, "Swap.total"=>4194300, "Swap.used"=>0, "Swap.free"=>4194300}]
[0] mem.local: [[1733829752.282912630, {}], {"Mem.total"=>16367268, "Mem.used"=>4856048, "Mem.free"=>11511220, "Swap.total"=>4194300, "Swap.used"=>0, "Swap.free"=>4194300}]
^C[2024/12/10 11:22:33] [engine] caught signal (SIGINT)
[2024/12/10 11:22:33] [ warn] [engine] service will shutdown in max 5 seconds
[0] mem.local: [[1733829753.282925712, {}], {"Mem.total"=>16367268, "Mem.used"=>4856048, "Mem.free"=>11511220, "Swap.total"=>4194300, "Swap.used"=>0, "Swap.free"=>4194300}]
[2024/12/10 11:22:34] [ info] [engine] service has stopped (0 pending tasks)
[2024/12/10 11:22:34] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2024/12/10 11:22:34] [ info] [output:stdout:stdout.0] thread worker #0 stopped

@drbugfinder-work
Copy link
Contributor Author

Valgrind output

==133894== Memcheck, a memory error detector
==133894== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==133894== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==133894== Command: ./fluent-bit -c fluent-bit.conf
==133894== 
Fluent Bit v3.2.3
* Copyright (C) 2015-2024 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____ 
|  ___| |                | |   | ___ (_) |         |____ |/ __  \
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   __   / /`' / /'
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \  / /  
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V /.___/ /./ /___
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)_____/


[2024/12/10 11:24:01] [ info] [fluent bit] version=3.2.3, commit=4ad29e201c, pid=133894
[2024/12/10 11:24:01] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/12/10 11:24:01] [ info] [simd    ] disabled
[2024/12/10 11:24:01] [ info] [cmetrics] version=0.9.9
[2024/12/10 11:24:01] [ info] [output:stdout:stdout.0] worker #0 started
[2024/12/10 11:24:01] [ info] [ctraces ] version=0.5.7
[2024/12/10 11:24:01] [ info] [input:mem:mem.0] initializing
[2024/12/10 11:24:01] [ info] [input:mem:mem.0] storage_strategy='memory' (memory only)
[2024/12/10 11:24:01] [ info] [sp] stream processor started
[0] mem.local: [[1733829842.321537269, {}], {"Mem.total"=>16367268, "Mem.used"=>4940584, "Mem.free"=>11426684, "Swap.total"=>4194300, "Swap.used"=>0, "Swap.free"=>4194300}]
[0] mem.local: [[1733829843.298349095, {}], {"Mem.total"=>16367268, "Mem.used"=>4940584, "Mem.free"=>11426684, "Swap.total"=>4194300, "Swap.used"=>0, "Swap.free"=>4194300}]
[0] mem.local: [[1733829844.286150530, {}], {"Mem.total"=>16367268, "Mem.used"=>4940584, "Mem.free"=>11426684, "Swap.total"=>4194300, "Swap.used"=>0, "Swap.free"=>4194300}]
^C[2024/12/10 11:24:05] [engine] caught signal (SIGINT)
[0] mem.local: [[1733829845.285280528, {}], {"Mem.total"=>16367268, "Mem.used"=>4940584, "Mem.free"=>11426684, "Swap.total"=>4194300, "Swap.used"=>0, "Swap.free"=>4194300}]
[2024/12/10 11:24:05] [ warn] [engine] service will shutdown in max 5 seconds
[2024/12/10 11:24:06] [ info] [engine] service has stopped (0 pending tasks)
[2024/12/10 11:24:06] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2024/12/10 11:24:06] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==133894== 
==133894== HEAP SUMMARY:
==133894==     in use at exit: 0 bytes in 0 blocks
==133894==   total heap usage: 1,900 allocs, 1,900 frees, 1,838,029 bytes allocated
==133894== 
==133894== All heap blocks were freed -- no leaks are possible
==133894== 
==133894== For lists of detected and suppressed errors, rerun with: -s
==133894== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant