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

Throttle filter add template support #3819

Merged
merged 4 commits into from Nov 4, 2021

Conversation

Kokan
Copy link
Collaborator

@Kokan Kokan commented Oct 22, 2021

This PR adds template supports, and as a last step removes value() option.
value("A") can be replaced with template("${A}").

This PR somewhat conflicts with:

I'll provide patches in those, but as the result no separate news entry is needed here.

Example config:

   throttle(
     template("${.journald._UID}")
     rate(1)
   );

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@Kokan Kokan added this to the syslog-ng-3.35 milestone Oct 28, 2021
OverOrion
OverOrion previously approved these changes Oct 28, 2021
Copy link
Collaborator

@OverOrion OverOrion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I have tried it out, it works as intended.

@Barkodcz
Copy link
Contributor

I found a crash :/

If I didn't set in the filter the template option.

Example config

source s_network {
	network(
		ip("0.0.0.0")
		port(6666)
	);
};

destination d_network {
	network(
		"127.0.0.1"
		port(6667)
	);
};

filter f_throttle {
	throttle(
		# template("") <-- I didn't set 
		rate(1)
	);
};

log {
	source(s_network);
	filter(f_throttle);
	destination(d_network);
};

@Kokan Kokan force-pushed the filter-throttle-template branch 2 times, most recently from 77d2881 to fc1d8c2 Compare October 29, 2021 12:06
@Kokan
Copy link
Collaborator Author

Kokan commented Oct 29, 2021

Nice catch, the last commit also removed the check if the template was provided (77d2881).

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@Barkodcz
Copy link
Contributor

LGTM, approve.

Barkodcz
Barkodcz previously approved these changes Oct 29, 2021
Signed-off-by: Kokan <kokaipeter@gmail.com>
Example:
```
throttle(
  rate(1)
  template("${.journald._UID}")
);
```

Signed-off-by: Kokan <kokaipeter@gmail.com>
Signed-off-by: Kokan <kokaipeter@gmail.com>
The new template support were added to throttle filter, a modification
only requires users to change value("A") --> template("${A}").

The template is a better option to have, the only downside could be
performance, but it is possible to use a lightweight version of template
called trivial template that is quick.

As all template containing only one NV key is trivial, this should not
cause a regression.

As the value option was never published in a release, it is safe to
remove and only provide template option.

Signed-off-by: Kokan <kokaipeter@gmail.com>
@Kokan
Copy link
Collaborator Author

Kokan commented Nov 3, 2021

Only rebased on current master to make CI happy.

@kira-syslogng
Copy link
Contributor

Build SUCCESS

Copy link
Collaborator

@OverOrion OverOrion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, approved!

@OverOrion OverOrion merged commit d8d09f8 into syslog-ng:master Nov 4, 2021
@Kokan Kokan deleted the filter-throttle-template branch November 4, 2021 07:44
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.

None yet

5 participants