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

in_dummy: Add flush_on_startup config. #8222

Merged
merged 1 commit into from Jan 12, 2024

Conversation

franciscovalentecastro
Copy link
Contributor

@franciscovalentecastro franciscovalentecastro commented Nov 27, 2023

This PR adds new flush_on_startup setting to the in_dummy input plugin. When interval_sec/nsec is set for a long time, its helpful to be able to verify the first event is generated at startup to avoid waiting.

Documentation update in fluent/fluent-bit-docs#1264.

Configuration

[INPUT]
    Dummy            {"message": "Dummy", "severity": "INFO"}
    Interval_NSec    0
    Interval_Sec     10
    Name             dummy
    Start_time_sec   0
    Flush_on_startup True

[OUTPUT]
    Name            stdout
    Match           *

Output Log

With this config a log message is generated at startup and then every 10 seconds.

./fluent-bit -c fluent-bit.conf
Fluent Bit v2.2.1
* Copyright (C) 2015-2023 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/11/27 21:22:50] [ info] [fluent bit] version=2.2.1, commit=8733b25df1, pid=1790739
[2023/11/27 21:22:50] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/11/27 21:22:50] [ info] [cmetrics] version=0.6.5
[2023/11/27 21:22:50] [ info] [ctraces ] version=0.3.1
[2023/11/27 21:22:50] [ info] [input:dummy:dummy.0] initializing
[2023/11/27 21:22:50] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/11/27 21:22:50] [ info] [sp] stream processor started
[2023/11/27 21:22:50] [ info] [output:stdout:stdout.0] worker #0 started
[0] dummy.0: [[0.000070090, {}], {"message"=>"Dummy", "severity"=>"INFO"}]
[0] dummy.0: [[9.447917175, {}], {"message"=>"Dummy", "severity"=>"INFO"}]
[0] dummy.0: [[19.447787506, {}], {"message"=>"Dummy", "severity"=>"INFO"}]
[0] dummy.0: [[29.447908652, {}], {"message"=>"Dummy", "severity"=>"INFO"}]
^C[2023/11/27 21:23:24] [engine] caught signal (SIGINT)
[2023/11/27 21:23:24] [ warn] [engine] service will shutdown in max 5 seconds
[2023/11/27 21:23:24] [ info] [input] pausing dummy.0
[2023/11/27 21:23:24] [ info] [engine] service has stopped (0 pending tasks)
[2023/11/27 21:23:24] [ info] [input] pausing dummy.0
[2023/11/27 21:23:24] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/11/27 21:23:24] [ info] [output:stdout:stdout.0] thread worker #0 stopped

Valgrind Output

valgrind --leak-check=yes ./fluent-bit   --config ./fluent-bit.conf
==1790816== Memcheck, a memory error detector
==1790816== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==1790816== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==1790816== Command: ./fluent-bit --config ./fluent-bit.conf
==1790816==
Fluent Bit v2.2.1
* Copyright (C) 2015-2023 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/11/27 21:23:46] [ info] [fluent bit] version=2.2.1, commit=8733b25df1, pid=1790816
[2023/11/27 21:23:46] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/11/27 21:23:46] [ info] [cmetrics] version=0.6.5
[2023/11/27 21:23:46] [ info] [ctraces ] version=0.3.1
[2023/11/27 21:23:46] [ info] [input:dummy:dummy.0] initializing
[2023/11/27 21:23:46] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/11/27 21:23:46] [ info] [sp] stream processor started
[2023/11/27 21:23:46] [ info] [output:stdout:stdout.0] worker #0 started
==1790816== Warning: client switching stacks?  SP change: 0x6cbae58 --> 0x517e0a0
==1790816==          to suppress, use: --max-stackframe=28560824 or greater
==1790816== Warning: client switching stacks?  SP change: 0x517df88 --> 0x6cbae58
==1790816==          to suppress, use: --max-stackframe=28561104 or greater
==1790816== Warning: client switching stacks?  SP change: 0x6cbae58 --> 0x517df88
==1790816==          to suppress, use: --max-stackframe=28561104 or greater
==1790816==          further instances of this message will not be shown.
[0] dummy.0: [[0.014987779, {}], {"message"=>"Dummy", "severity"=>"INFO"}]
[0] dummy.0: [[9.137168279, {}], {"message"=>"Dummy", "severity"=>"INFO"}]
[0] dummy.0: [[19.135748536, {}], {"message"=>"Dummy", "severity"=>"INFO"}]
^C[2023/11/27 21:24:07] [engine] caught signal (SIGINT)
[2023/11/27 21:24:07] [ warn] [engine] service will shutdown in max 5 seconds
[2023/11/27 21:24:07] [ info] [input] pausing dummy.0
[2023/11/27 21:24:08] [ info] [engine] service has stopped (0 pending tasks)
[2023/11/27 21:24:08] [ info] [input] pausing dummy.0
[2023/11/27 21:24:08] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/11/27 21:24:08] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==1790816==
==1790816== HEAP SUMMARY:
==1790816==     in use at exit: 0 bytes in 0 blocks
==1790816==   total heap usage: 1,755 allocs, 1,755 frees, 1,875,538 bytes allocated
==1790816==
==1790816== All heap blocks were freed -- no leaks are possible
==1790816==
==1790816== For lists of detected and suppressed errors, rerun with: -s
==1790816== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

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.

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

Documentation

  • Documentation required for this feature

Backporting

  • 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.

Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
Copy link
Contributor

@braydonk braydonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @nokute78 please take a look

Copy link
Collaborator

@nokute78 nokute78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Note: If user doesn't set Match, fluent-bit doesn't flush on startup.
I think it is not related this PR and I believe user should set Match.

[INPUT]
    Name dummy
    Interval_Sec 10
    Flush_On_Startup true

[OUTPUT]
    Name stdout
#   Match *

@edsiper edsiper merged commit f8bd0ce into fluent:master Jan 12, 2024
51 checks passed
shaerpour pushed a commit to shaerpour/fluent-bit that referenced this pull request Jan 16, 2024
Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
shaerpour pushed a commit to shaerpour/fluent-bit that referenced this pull request Jan 16, 2024
Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
Signed-off-by: ahspw <ahspvirtuallife@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants