Skip to content

[Feature Request] <or> - logical or between checks #9

Description

@DopeforHope

Hello,

again, thanks for the work on the negate flag. However I noticed one use-case which isn't possible to cover with the plugin right now.

Let's assume we have the following use-case:
I want to filter out all JSONs with the value foo for the keys key1 and key2. However, I'm fine if one of the keys has the value foo but not both.

Exemplary JSONs:

{ "key1": "foo", "key2": "foo" } #shall not pass
{ "key1": "foo", "key2": "test" } #shall pass
{ "key1": "test", "key2": "foo" } #shall pass

As for as I know, the nearest I can get with this plugin is the following:

<filter **>
 @type json
 @id json_filter

  <check>
    path /key1
    pattern /^(?!foo)/
  </check>
  <check>
    path /key2
    pattern /^(?!foo)/
  </check>
</filter>

However in the following, all three exemplary JSONs would be filtered out. I don't see a way to implement it with this plugin. The reason is that consecutive check are evaluated with a logical AND in between. However, the logical OR operator is non existent as far as I know.

Therefore I would propose an <or>-tag like in the FluentD grep module: https://docs.fluentd.org/filter/grep#less-than-or-greater-than-directive

With this one, one should be able to filter out the value as desired:

<filter **>
 @type json
 @id json_filter

  <or>
    <check>
      path /key1
      pattern /^(?!foo)/
    </check>
    <check>
      path /key2
      pattern /^(?!foo)/
    </check>
  </or>
</filter>

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions