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
Add log throttling in files based on group rules #3535
Add log throttling in files based on group rules #3535
Conversation
|
The concept would be nice, but implementing it as another plugin isn't good idea.
If a user wants feature1 and feature3, which plugin the user should select? On the other hand, current in_tail’s code is complicated, I think refactoring might be needed before adding new major features. |
Thank you for all your valuable feedback. In the in_tail plugin, one can rate limit using
Do you want to keep a separate plugin in this repository until in_tail is refactored and then merge it later? |
|
@ashie can you further guide on this PR merging ? please note both in_tail and in_tail_with_throttle can co-exists and one can use both of them as set of |
|
My additional impressions:
|
@ashie Our plugin has the following advantages :
Adding regexp based path parameter to in_tail will add multiple source plugins which will create additional threads for reading from files. Hence cpu cycles will be wasted in context switching.
in_tail_with_throttle allows you to have generic and context-specifc rules for log rate limit. It will be difficult to manage with in_tail's path parameter based grouping and can lead to files falling In more than one group. For example, consider the following requirement: in_tail_with_throttle will add a file with DEF app name and ABC namespace to rule 2 (Higher precedence over rule1). Using in_tail's path parameter will add the file in two groups and hence repeated log lines will be collected.
In cases where we forget to add rules for some files, in_tail_with_throttle will add them to the default group and still collect logs. in_tail plugin with regex based path parameter grouping will fail in these situations.
Adding multiple source configs for in_tail's path based grouping will make your configuration file big in size. It will be difficult to manage and update configurations in case of very large number of groups. |
@ashie can you please elaborate on what this generalisation means? Should we replace our namespace and app-name fields with something else? For example, |
|
@ashie Could you please comment? |
cacc2c7
to
514126c
Compare
|
@cosmo0920 would you also be able to take a look? |
I reviewed and added a few concerns. Could you take a look about them?
Thanks for revising the patch, it's much better than before!
I'm sorry for my late response, I was thinking how to resolve remaining issues.
I commented about it above, please check it.
514126c
to
13fc410
Compare
Implementation idea is good. But, I found a nitpick issue for a constant name.
|
The big picture seems good, I'll check further more details, please wait for a few days... |
|
A test always fails: |
Signed-off-by: Pranjal Gupta <pranjal.gupta2@ibm.com>
Signed-off-by: Pranjal Gupta <pranjal.gupta2@ibm.com>
…r than string Signed-off-by: Pranjal Gupta <pranjal.gupta2@ibm.com>
Signed-off-by: Pranjal Gupta <pranjal.gupta2@ibm.com>
Signed-off-by: Pranjal Gupta <pranjal.gupta2@ibm.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
I'll add more commits directly to your branch to polish up the code.
Please feel free to comment on them if you have any problems.
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
add_group_watcher -> add_path_to_group_watcher remove_group_watcher -> remove_path_from_group_watcher And simplify them. Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
| end | ||
|
|
||
| def remove_path_from_group_watcher(path) | ||
| return if @group.nil? |
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.
Should we return nil on remove_path_from_group_watcher as well?
This is just nitpick and not important.
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
/home/aho/Projects/Fluentd/fluentd/test/plugin/test_in_tail.rb:183: warning: assigned but unused variable - d /home/aho/Projects/Fluentd/fluentd/test/plugin/test_in_tail.rb:205: warning: assigned but unused variable - d /home/aho/Projects/Fluentd/fluentd/test/plugin/test_in_tail.rb:220: warning: assigned but unused variable - d /home/aho/Projects/Fluentd/fluentd/test/plugin/test_in_tail.rb:385: warning: ambiguous first argument; put parentheses or a space even after `-' operator /home/aho/Projects/Fluentd/fluentd/lib/fluent/plugin/in_tail/group_watch.rb:123: warning: assigned but unused variable - e Signed-off-by: Takuro Ashie <ashie@clear-code.com>
|
Hmm, it takes too long time to run tests, more than 1 minutes longer than before: master branch: $ time bundle exec rake test TEST=test/plugin/test_in_tail.rb
...
real 2m33.910s
user 0m3.410s
sys 0m0.322sthis branch: $ time bundle exec rake test TEST=test/plugin/test_in_tail.rb
...
real 3m36.044s
user 0m3.807s
sys 0m0.335sWe should shorten it if it's possible since it's affect to whole debugging efficiency. |
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Trying to improve it by efa7d2d |
It's also fine on CI. |
|
I'll merge this after checking group_watch.rb once more. |
$ time bundle exec rake test TEST=test/plugin/test_in_tail.rb
...
real 2m45.993s
user 0m3.642s
sys 0m0.266s |
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
safety_mergin -> safety_ratio Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
|
Merged. |
|
Thanks @ashie @cosmo0920 @agup006 for your help and support! I am glad that it got merged! |
Which issue(s) this PR fixes:
None
What this PR does / why we need it:
Fluentd running in a big cluster with a high volume of logs has to deal with a lot of applications logging at different rates. High log generation rates for low priority applications can lead to log loss for high priority applications. We need to have a data flow control in the log collector so that we can limit the log collection rate of applications based on the priority of application workloads in the cluster.
Tail Plugin is watching a file and reads logs till it reaches the end of the file. Earlier accepted PR #3185 introduced throttling at the source level which applies a limit to the number of bytes collected by the in_tail plugin every second. However, it uniformly applies the same limit to every log file.
This PR enables us to form different groups based on configuration rules provided by the user. Within each group, one can set the rate limits for log collection. The set rate limit gets uniformly applied to each member (log file) of the group. If the group line limit of the log is reached within the
rate_periodtime interval, Fluentd stops reading logs from that group. Once,rate_period(time) is over, Fluentd resets its group counters and restarts the reading process.I strongly believe group level rate limiting can really help one to control low priority applications vs high priority applications log flow. Currently based on the namespace and app name (application name) extracted from file names, one can form groups for rate limiting.
Docs Changes:
fluent/fluentd-docs-gitbook#376
Release Note:
Same as Title