-
Notifications
You must be signed in to change notification settings - Fork 17
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: load_vars()
#393
filterx: load_vars()
#393
Conversation
So we can restore them better. Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
f57547b
to
fd64415
Compare
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
fd64415
to
18918e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, I only have scenario that I think is worth a short discussion:
What should happen if the to be loaded json contains a $MSG
as key for example?
The current behavior is that the json's $MSG
key is resolved first (e.g., "foo"
) and then it will be loaded as {"foo": "some_val"}
.
I am not certain whether the user would have wanted to actually overwrite $MSG
or not in this case 😕.
log {
source{stdin(flags(no-parse));};
filterx{
my_vars = {"var1":"foo","var2":["foo","bar"],"$MSG":"msg_overwritten"};
load_vars(my_vars);
vars();
};
destination{stdout();};
};
[2024-11-26T13:07:37.132156] Incoming log entry; input='hello', msg='0x7955a8011cc0', rcptid='5644'
....
[2024-11-26T13:07:37.132156] FILTERX ESTEP; expr='foobar.conf:13:5| vars()', value='{"$MESSAGE":"hello","my_vars":{"var1":"foo","var2":["foo","bar"],"hello":"msg_overwritten"},"var1":"foo","var2":["foo","bar"],"hello":"msg_overwritten"}', truthy='1', type='json_object'
....
[2024-11-26T13:07:37.133140] Outgoing message; message='Nov 26 13:07:37 orion-T14G3 hello\x0a'
That is caused by an unintuitive template resolution, I think. syslog-ng.conf:
vars.json:
|
Inverse of
vars()
.Note: FilterX level variables are loaded and
declare
d.