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

add black list to aviod take too much efforts to translate in file log watcher #961

Conversation

smileusd
Copy link
Contributor

This pr is to add black list in file log watcher to skip the translat which take too much overhead in cpu when log flush outburst #960

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 29, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @smileusd. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 29, 2024
@wangzhen127
Copy link
Member

Do you always know what pattern to skip in the log? Can you provide a sample config file with the blacklist for your target use case?

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 2, 2024
Comment on lines 137 to 139
if s.cfg.BlackList == nil || len(s.cfg.BlackList) == 0 {
return false
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this adds much value. Range should be able to handle nil or empty slices.

Suggested change
if s.cfg.BlackList == nil || len(s.cfg.BlackList) == 0 {
return false
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 39 to 40
// Skip the black list by simple filter to avoid running more efforts in regex
BlackList []string `json:"blackList,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Skip the black list by simple filter to avoid running more efforts in regex
BlackList []string `json:"blackList,omitempty"`
// Skip the log lines containing any of the strings in the list to avoid running unnecessary regex.
SkipList []string `json:"skipList,omitempty"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@smileusd
Copy link
Contributor Author

smileusd commented Oct 9, 2024

Do you always know what pattern to skip in the log? Can you provide a sample config file with the blacklist for your target use case?

/ok-to-test

In our cluster, the users deploy the audit beat pod and record the log with all files changed in /var/log/messages. So we skip log simply contains the "audit:" and "audit[" .

root@~# tail  -n 10000 /var/log/messages |grep audit |wc -l 
9554

There is 95% useless logs in NPD impact the performance

@smileusd smileusd force-pushed the upstream_add_black_list_in_log_watcher branch from c7b9f37 to 2b5c836 Compare October 9, 2024 11:55
@smileusd
Copy link
Contributor Author

/test pull-npd-e2e-test

@hakman
Copy link
Member

hakman commented Oct 11, 2024

/lgtm
/assign @wangzhen127

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 11, 2024
@@ -116,6 +116,9 @@ func (s *filelogWatcher) watchLoop() {
}
line = buffer.String()
buffer.Reset()
if s.filterSkipList(line) {
continue
Copy link
Member

Choose a reason for hiding this comment

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

Can you add some test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -36,6 +36,8 @@ type WatcherConfig struct {
// PluginConfig is a key/value configuration of a plugin. Valid configurations
// are defined in different log watcher plugin.
PluginConfig map[string]string `json:"pluginConfig,omitempty"`
// Skip the log lines containing any of the strings in the list to avoid running unnecessary regex.
SkipList []string `json:"skipList,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a sample config file in https://github.com/kubernetes/node-problem-detector/tree/master/config to illustrate how to use this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 15, 2024
Copy link
Member

@wangzhen127 wangzhen127 left a comment

Choose a reason for hiding this comment

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

Can you also squash the commits?

@@ -9,6 +9,7 @@
"lookback": "5m",
"bufferSize": 10,
"source": "docker-monitor",
"skipList": [],
Copy link
Member

Choose a reason for hiding this comment

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

No need to add empty list in existing files. We need to make sure when it is missing, those files still work for backward compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -9,6 +9,7 @@
"lookback": "5m",
"bufferSize": 10,
"source": "kernel-monitor",
"skipList": [ " audit:", " audit[" ],
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove from this file and add a new json file with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@wangzhen127
Copy link
Member

BTW, we plan to make a new release this week. If you can get the PR ready in a day or two, we can include it in the upcoming release. Otherwise, it can wait for the next release.

/retest

@smileusd smileusd force-pushed the upstream_add_black_list_in_log_watcher branch from 81d34d2 to 3a386a6 Compare October 16, 2024 02:57
@wangzhen127
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 16, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman, smileusd, wangzhen127

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 16, 2024
@k8s-ci-robot k8s-ci-robot merged commit 0f4d8b9 into kubernetes:master Oct 16, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants