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_expect: support 'result_key' property and add test code #5668

Merged
merged 2 commits into from
Jul 6, 2022

Conversation

nokute78
Copy link
Collaborator

@nokute78 nokute78 commented Jul 3, 2022

This patch is to

  • Support result_key property and action result_key
  • Add test code for filter_expect

A property action result_key will append a result that rule is matched or not.
It is useful to test to check if the result value is true or false.


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.

Documentation

  • [N/A] Documentation required for this feature

Backporting

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

Configuration

[INPUT]
    Name dummy

[FILTER]
    Name Expect
    Match *
    Action result_key
    result_key result_is
    Key_Not_Exists hoge

[OUTPUT]
    Name stdout
    Match *

Debug log / Valgrind output

The key result_is is added.

[1656831381.289275294, {"result_is"=>true, "message"=>"dummy"}]
$ valgrind --leak-check=full bin/fluent-bit -c expect.conf 
==98553== Memcheck, a memory error detector
==98553== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==98553== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==98553== Command: bin/fluent-bit -c expect.conf
==98553== 
Fluent Bit v1.9.6
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2022/07/03 15:56:19] [ info] [fluent bit] version=1.9.6, commit=7b23b94676, pid=98553
[2022/07/03 15:56:19] [ info] [storage] version=1.2.0, type=memory-only, sync=normal, checksum=disabled, max_chunks_up=128
[2022/07/03 15:56:19] [ info] [cmetrics] version=0.3.5
[2022/07/03 15:56:19] [ info] [output:stdout:stdout.0] worker #0 started
[2022/07/03 15:56:19] [ info] [sp] stream processor started
[0] dummy.0: [1656831380.296893567, {"result_is"=>true, "message"=>"dummy"}]
^C[2022/07/03 15:56:22] [engine] caught signal (SIGINT)
[0] dummy.0: [1656831381.289275294, {"result_is"=>true, "message"=>"dummy"}]
[2022/07/03 15:56:22] [ warn] [engine] service will shutdown in max 5 seconds
[2022/07/03 15:56:22] [ info] [engine] service has stopped (0 pending tasks)
[2022/07/03 15:56:22] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2022/07/03 15:56:22] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==98553== 
==98553== HEAP SUMMARY:
==98553==     in use at exit: 0 bytes in 0 blocks
==98553==   total heap usage: 1,233 allocs, 1,233 frees, 953,706 bytes allocated
==98553== 
==98553== All heap blocks were freed -- no leaks are possible
==98553== 
==98553== For lists of detected and suppressed errors, rerun with: -s
==98553== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

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: Takahiro Yamashita <nokute78@gmail.com>
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
@nokute78 nokute78 changed the title filter_expect: support 'result_key' property filter_expect: support 'result_key' property and add test code Jul 3, 2022
@nokute78
Copy link
Collaborator Author

nokute78 commented Jul 3, 2022

Doc PR is fluent/fluent-bit-docs#836

@edsiper edsiper merged commit 2d65069 into fluent:master Jul 6, 2022
@nokute78 nokute78 deleted the test_filter_expect branch July 7, 2022 11:35
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.

2 participants