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 interval settings. #8060

Merged
merged 5 commits into from Nov 6, 2023

Conversation

franciscovalentecastro
Copy link
Contributor

@franciscovalentecastro franciscovalentecastro commented Oct 18, 2023

This PR adds new interval_sec and interval_nsec settings to the in_dummy input plugin. This settings enable to set an arbitrary time interval in which to generate dummy logs. When interval_sec/nsec is set correctly, the rate configuration is ignored.
Documentation update in fluent/fluent-bit-docs#1239.

Configuration

[INPUT]
    Name          dummy
    Dummy         {"message": "custom dummy"}
    Interval_sec  1
    Interval_nsec 500000000
    Rate          0

[OUTPUT]
    Name   stdout
    Match  *

Output Log

With this config a log message is generated every 1.5 seconds).

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

[2023/10/27 18:06:56] [ info] [fluent bit] version=2.2.0, commit=785f45a16d, pid=1533032
[2023/10/27 18:06:56] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/10/27 18:06:56] [ info] [cmetrics] version=0.6.3
[2023/10/27 18:06:56] [ info] [ctraces ] version=0.3.1
[2023/10/27 18:06:56] [ info] [input:dummy:dummy.0] initializing
[2023/10/27 18:06:56] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/10/27 18:06:56] [ info] [sp] stream processor started
[2023/10/27 18:06:56] [ info] [output:stdout:stdout.0] worker #0 started
[0] dummy.0: [[1698430017.644439396, {}], {"message"=>"custom dummy"}]
[0] dummy.0: [[1698430019.144370981, {}], {"message"=>"custom dummy"}]
[0] dummy.0: [[1698430020.644434995, {}], {"message"=>"custom dummy"}]
[0] dummy.0: [[1698430022.144357678, {}], {"message"=>"custom dummy"}]
^C[2023/10/27 18:07:03] [engine] caught signal (SIGINT)
[2023/10/27 18:07:03] [ warn] [engine] service will shutdown in max 5 seconds
[2023/10/27 18:07:03] [ info] [input] pausing dummy.0
[2023/10/27 18:07:03] [ info] [engine] service has stopped (0 pending tasks)
[2023/10/27 18:07:03] [ info] [input] pausing dummy.0
[2023/10/27 18:07:03] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/10/27 18:07:03] [ info] [output:stdout:stdout.0] thread worker #0 stopped

Valgrind Output

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

[2023/10/27 18:06:01] [ info] [fluent bit] version=2.2.0, commit=785f45a16d, pid=1533023
[2023/10/27 18:06:01] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/10/27 18:06:01] [ info] [cmetrics] version=0.6.3
[2023/10/27 18:06:01] [ info] [ctraces ] version=0.3.1
[2023/10/27 18:06:01] [ info] [input:dummy:dummy.0] initializing
[2023/10/27 18:06:01] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/10/27 18:06:01] [ info] [sp] stream processor started
[2023/10/27 18:06:01] [ info] [output:stdout:stdout.0] worker #0 started
[0] dummy.0: [[1698429961.660134534, {}], {"message"=>"custom dummy"}]
[0] dummy.0: [[1698429963.144432977, {}], {"message"=>"custom dummy"}]
[0] dummy.0: [[1698429964.644634450, {}], {"message"=>"custom dummy"}]
[0] dummy.0: [[1698429966.144556969, {}], {"message"=>"custom dummy"}]
^C[2023/10/27 18:06:07] [engine] caught signal (SIGINT)
[2023/10/27 18:06:07] [ warn] [engine] service will shutdown in max 5 seconds
[2023/10/27 18:06:07] [ info] [input] pausing dummy.0
[2023/10/27 18:06:07] [ info] [engine] service has stopped (0 pending tasks)
[2023/10/27 18:06:07] [ info] [input] pausing dummy.0
[2023/10/27 18:06:07] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/10/27 18:06:07] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==1533023==
==1533023== HEAP SUMMARY:
==1533023==     in use at exit: 0 bytes in 0 blocks
==1533023==   total heap usage: 1,716 allocs, 1,716 frees, 1,779,752 bytes allocated
==1533023==
==1533023== All heap blocks were freed -- no leaks are possible
==1533023==
==1533023== For lists of detected and suppressed errors, rerun with: -s
==1533023== 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.

@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 18, 2023 19:20 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 18, 2023 19:20 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 18, 2023 19:20 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 18, 2023 19:46 — with GitHub Actions Inactive
plugins/in_dummy/in_dummy.c Outdated Show resolved Hide resolved
plugins/in_dummy/in_dummy.c Outdated Show resolved Hide resolved
braydonk
braydonk previously approved these changes Oct 19, 2023
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.

Realized after talking offline that we should add some tests for this to in_simple_systems.c

@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 27, 2023 17:55 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 27, 2023 17:55 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 27, 2023 17:55 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro changed the title in_dummy: Add time_interval setting. in_dummy: Add interval_(sec|nsec) setting. Oct 27, 2023
Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 27, 2023 18:14 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 27, 2023 18:14 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 27, 2023 18:14 — with GitHub Actions Inactive
@franciscovalentecastro franciscovalentecastro changed the title in_dummy: Add interval_(sec|nsec) setting. in_dummy: Add interval settings. Oct 27, 2023
Signed-off-by: Francisco Valente <1435136+franciscovalentecastro@users.noreply.github.com>
@franciscovalentecastro franciscovalentecastro temporarily deployed to pr October 27, 2023 18:47 — with GitHub Actions Inactive
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.

@franciscovalentecastro Thank you! LGTM.

@braydonk
Copy link
Contributor

Those MacOS test failures look unrelated to this PR.

@braydonk
Copy link
Contributor

Thanks @nokute78!

tests/runtime/in_simple_systems.c doesn't have a listing in CODEOWNERS (would that make sense for it to be you?)

This means I think we need approval from one of the default folks. @edsiper @leonardo-albertovich if you are able to.

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