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

Enhancement: conditional set-tag() #1521

Closed
faxm0dem opened this issue Jun 6, 2017 · 2 comments · Fixed by #3190
Closed

Enhancement: conditional set-tag() #1521

faxm0dem opened this issue Jun 6, 2017 · 2 comments · Fixed by #3190

Comments

@faxm0dem
Copy link
Contributor

faxm0dem commented Jun 6, 2017

It would be nice to have this in our toolbox, together with conditional set().

Cheers

@mehul-m-prajapati
Copy link
Contributor

Hi @faxm0dem,

I can see KW_SET_TAG is already there in lib/rewrite/rewrite-expr-grammar.ym.
Can you give me a brief idea about what enhancement is required for set-tag() ?

@furiel
Copy link
Collaborator

furiel commented Mar 17, 2020

Some rewrite rules already accept a condition option. Though set-tag does not accept it yet. In the meantime, grammar level if statement was introduced, that can cover this use case as well.

Still, I think set-tag("tag" condition(filter-expression)); is a neat syntax, and I would happy to see it implemented.
With a little code reorganization and a well placed rewrite_condition_opt in the grammar, this can work.

@version: 3.26

log {
  source { example-msg-generator(num(1) template("test message")); };
  rewrite { set-tag("matching-tag" condition(match("test" value("MSG")))); };
  rewrite { set-tag("non-matching-tag" condition(match("donotmatch" value("MSG")))); };
  destination { file("/dev/stdout" template("${TAGS}\n")); };
};

outputting:

[2020-03-17T09:36:01.797268] syslog-ng starting up; version='3.26.1.43.g0b84be1.dirty'
matching-tag,.source.#anon-source0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants