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

Rate limit notifications #161

Merged
merged 2 commits into from
Dec 8, 2016
Merged

Rate limit notifications #161

merged 2 commits into from
Dec 8, 2016

Conversation

mstemm
Copy link
Contributor

@mstemm mstemm commented Dec 8, 2016

Add rate limiting for notifications, so even if a rule is extremely noisy it won't result in a flood of notifications.

This is one of the fixes for #156.

The second argument to handle_event is actually a rule name, but the
variable was a misleading "level". Fix.
Add token-bucket based rate limiting for falco notifications.

The token bucket is implemented in token_bucket.cpp (actually in the
engine directory, just to make it easier to include in other
programs). It maintains a current count of tokens (i.e. right to send a
notification). Its main method is claim(), which attemps to claim a
token and returns true if one was claimed successfully. It has a
configurable configurable max burst size and rate. The token bucket
gains "rate" tokens per second, up to a maximum of max_burst tokens.

These parameters are configurable in falco.yaml via the config
options (defaults shown):

outputs:
  rate: 1
  max_burst: 1000

In falco_outputs::handle_event(), try to claim a token, and if
unsuccessful log a debug message and return immediately.
@mstemm mstemm merged commit 54b30bc into dev Dec 8, 2016
@mstemm mstemm deleted the rate-limit-notifications branch December 8, 2016 17:46
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

1 participant