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

Filterx: add drop/done #269

Merged
merged 12 commits into from
Sep 9, 2024
Merged

Filterx: add drop/done #269

merged 12 commits into from
Sep 9, 2024

Conversation

OverOrion
Copy link
Contributor

@OverOrion OverOrion commented Sep 2, 2024

Example config

log {

  source { example-msg-generator(num(1) template("bar")); };
  source { example-msg-generator(num(1) template("foo")); };
  filterx {
    if ($MSG =~ '.*foo.*' ){
      drop;
    }
    else {
      done;
      declare var_should_not_exist = json(); # This will be skipped
    };

  };
  filterx {
    vars();
  };
  destination { file("/dev/stdout"); };
};

Result

Setting value; name='MESSAGE', value='-- Generated message. --', type='string', msg='0x6500309ffa40', rcptid='28'
Setting value; name='MESSAGE', value='bar', type='string', msg='0x6500309ffa40', rcptid='28'
Incoming generated message; msg='bar'
>>>>>> Source side message processing begin; location='./etc/drop_msg.conf:5:12', msg='0x6500309ffa40', rcptid='28'
Setting value; name='HOST_FROM', value='orion-T14G3', type='string', msg='0x6500309ffa40', rcptid='28'
Setting value; name='HOST', value='orion-T14G3', type='string', msg='0x6500309ffa40', rcptid='28'
Setting tag; name='.source.#anon-source0', value='1', msg='0x6500309ffa40'
Setting value; name='SOURCE', value='#anon-source0', type='string', msg='0x6500309ffa40', rcptid='28'
>>>>>> filterx rule evaluation begin; rule='#anon-filter0', location='./etc/drop_msg.conf:7:10', msg='0x6500309ffa40', rcptid='28'
FILTERX CONDF; expr='./etc/drop_msg.conf:8:9|      $MSG =~ \'.*foo.*\'', value='false', truthy='0', type='boolean'
FILTERX ESTEP; expr='./etc/drop_msg.conf:12:7|     done', value='true', truthy='1', type='boolean'
<<<<<< filterx rule evaluation result; result='matched', rule='#anon-filter0', location='./etc/drop_msg.conf:7:10', dirty='1', msg='0x6500309ffa40', rcptid='28'
>>>>>> filterx rule evaluation begin; rule='#anon-filter1', location='./etc/drop_msg.conf:17:10', msg='0x6500309ffa40', rcptid='28'
FILTERX ESTEP; expr='./etc/drop_msg.conf:18:5|     vars()', value='{"MESSAGE":"bar"}', truthy='1', type='json_object'
<<<<<< filterx rule evaluation result; result='matched', rule='#anon-filter1', location='./etc/drop_msg.conf:17:10', dirty='1', msg='0x6500309ffa40', rcptid='28'
Filterx sync: variable in scope and message in sync, not doing anything; variable='MESSAGE'
Initializing destination file writer; template='/dev/stdout', filename='/dev/stdout', symlink_as='(null)'
affile_open_file; path='/dev/stdout', fd='13'
<<<<<< Source side message processing finish; location='./etc/drop_msg.conf:5:12', msg='0x6500309ffa40', rcptid='28'
Setting value; name='MESSAGE', value='-- Generated message. --', type='string', msg='0x650030a02fd0', rcptid='29'
Setting value; name='MESSAGE', value='foo', type='string', msg='0x650030a02fd0', rcptid='29'
Incoming generated message; msg='foo'
>>>>>> Source side message processing begin; location='./etc/drop_msg.conf:6:12', msg='0x650030a02fd0', rcptid='29'
Setting value; name='HOST_FROM', value='orion-T14G3', type='string', msg='0x650030a02fd0', rcptid='29'
Setting value; name='HOST', value='orion-T14G3', type='string', msg='0x650030a02fd0', rcptid='29'
Setting tag; name='.source.#anon-source1', value='1', msg='0x650030a02fd0'
Setting value; name='SOURCE', value='#anon-source1', type='string', msg='0x650030a02fd0', rcptid='29'
>>>>>> filterx rule evaluation begin; rule='#anon-filter0', location='./etc/drop_msg.conf:7:10', msg='0x650030a02fd0', rcptid='29'
FILTERX CONDT; expr='./etc/drop_msg.conf:8:9|      $MSG =~ \'.*foo.*\'', value='true', truthy='1', type='boolean'
FILTERX ESTEP; expr='./etc/drop_msg.conf:9:7|      drop', value='true', truthy='1', type='boolean'
<<<<<< filterx rule evaluation result; result='explicitly dropped', rule='#anon-filter0', location='./etc/drop_msg.conf:7:10', dirty='1', msg='0x650030a02fd0', rcptid='29'
Window size adjustment; old_window_size='99', window_size_increment='1', suspended_before_increment='FALSE', last_ack_type_is_suspended='FALSE'
<<<<<< Source side message processing finish; location='./etc/drop_msg.conf:6:12', msg='0x650030a02fd0', rcptid='29'
Outgoing message; message='Sep  2 18:40:03 orion-T14G3 bar\x0a'
Sep  2 18:40:03 orion-T14G3 bar

``

@OverOrion OverOrion force-pushed the filterx-drop-done branch 3 times, most recently from 86d3fa5 to 36e3a20 Compare September 2, 2024 16:49
@OverOrion OverOrion marked this pull request as ready for review September 3, 2024 07:08
lib/filterx/filterx-error.h Outdated Show resolved Hide resolved
lib/filterx/filterx-eval.c Outdated Show resolved Hide resolved
lib/filterx/filterx-eval.c Outdated Show resolved Hide resolved
lib/filterx/expr-compound.c Show resolved Hide resolved
lib/filterx/expr-compound.c Outdated Show resolved Hide resolved
lib/filterx/expr-drop.h Outdated Show resolved Hide resolved
lib/filterx/expr-done.h Outdated Show resolved Hide resolved
lib/filterx/filterx-eval.h Show resolved Hide resolved
lib/filterx/filterx-grammar.ym Outdated Show resolved Hide resolved
lib/filterx/expr-compound.c Outdated Show resolved Hide resolved
@alltilla
Copy link
Member

alltilla commented Sep 4, 2024

Also, please add some light tests. Thanks!

@alltilla alltilla merged commit 4b65700 into axoflow:main Sep 9, 2024
22 checks passed
fekete-robert pushed a commit to axoflow/axosyslog-core-docs that referenced this pull request Nov 9, 2024
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.

2 participants