Skip to content

Conversation

@marcosdiez
Copy link
Contributor

@marcosdiez marcosdiez commented May 12, 2022

Documentation: fluent/fluent-bit-docs#810

The grep filter does uses regexes only to match strings.
So I added a few arithmetic operators to match numbers (booleans, ints, floats and doubles):

  • number_equal
  • number_not_equal
  • number_less_than
  • number_less_than_or_equal
  • number_greater_than
  • number_greater_than_or_equal

Simple example to test:

[SERVICE]
    flush        1
    daemon       Off
    parsers_file parsers.conf
    plugins_file plugins.conf

[INPUT]
    Name         dummy
    dummy        {"message":"dummy", "aaaa": "bbb", "cccc": 128, "ddd": 20}


[FILTER]
    name    grep
    match   *
    # number_greater_than   ddd 40 # will not display any output
    number_greater_than   ddd 10 # will     display   output

[OUTPUT]
    name  stdout
    match *

debug output: https://gist.github.com/marcosdiez/52f1aca31ac69dda43c3dbe2d56e4ad0
Valgrind output: https://gist.github.com/marcosdiez/7f37b3e53a5252c2c33569e01e5b79d2


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.

@marcosdiez marcosdiez force-pushed the grep_arithmetic_operators branch from b8ef5ce to 21a766d Compare May 12, 2022 23:56
@nokute78
Copy link
Collaborator

I think it is better to create new filter plugin to support these operators.
Because grep command doesn't support these operations.

@marcosdiez
Copy link
Contributor Author

marcosdiez commented May 15, 2022 via email

@agup006
Copy link
Member

agup006 commented May 26, 2022

I'm +1 to having this in grep filter for now. We most likely need a longer-term implementation on comparisons (str + numbers). Though I don't think it should block progress for solving the current challenge. cc @nokute78

@nokute78
Copy link
Collaborator

nokute78 commented May 28, 2022

The basis of grep is match or not match pattern.
https://linux.die.net/man/1/grep

grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN.

I agree to support to check if the number is matched or not.

On the other hand, comparison operation is not supported by grep.
Such operations are supported by awk and so on.
That's why I requested to create new plugin.

One last argument against creating a new filter is that we already have "Modify" and "Record Modifier" which are confusing enough and parially redundant.

I agree and it is complicated for user...
But I think Comparing number and Matching pattern are different functionalities.

I am not sure what we should call it. Numerical Parser? Numerical Evaluator? Algebric log entry remover? Number Comparer?

Naming is one of difficult things.
I'm not familiar with English, so I can't help it :( ...
filter_compare_num like filter_rewrite_tag ? Hmm..

@patrick-stephens
Copy link
Collaborator

See fluent/fluent-bit-docs#810

@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Oct 28, 2022
@github-actions github-actions bot removed the Stale label Aug 15, 2024
@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Nov 26, 2024
@github-actions github-actions bot removed the Stale label Mar 21, 2025
@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Aug 27, 2025
@eschabell
Copy link

@marcosdiez can you take a look at resolving the conflicts in this PR?

@github-actions github-actions bot removed the Stale label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants