67 Commits
Author SHA1 Message Date
kubernetes-prow[bot]andGitHub aab5e5e2bb Merge pull request #1323 from hakman/precompile-log-buffer-regexps
Precompile log buffer regular expressions
2026-07-26 08:59:52 +00:00
Ciprian Hacman b02e2dcd09 Precompile log buffer regular expressions
Compile fixed patterns during monitor and log counter initialization, pass compiled expressions to the log buffer, and reject invalid log counter patterns before watching logs.
2026-07-25 09:21:31 +03:00
kubernetes-prow[bot]andGitHub 4cc149d1ab Merge pull request #1318 from hakman/fix-config-json-trailing-commas
Fix invalid config JSON and enforce canonical config format
2026-07-22 09:03:45 +00:00
Ciprian Hacman 87dfadb120 Fix invalid config JSON and enforce canonical config format
config/disk-log-message-filelog.json contained trailing commas and no
trailing newline, so it could not be parsed by encoding/json and NPD
would fail to start when configured with it.

- Fix the invalid JSON
- Add TestShippedConfigs, which verifies that every shipped JSON config
  under config/ (top level and one directory down) parses (catching
  trailing commas, UTF-8 BOMs and other syntax errors) and is in the
  canonical format (2-space indent, trailing newline), showing a diff on
  failure
- Add `make fmt-configs` to rewrite nonconforming files in place
  (UPDATE_EXPECTED=y)
- Normalize the existing config files to the canonical format
  (whitespace-only changes)
2026-07-22 07:58:20 +03:00
Veer Singh be4034f35a Cache compiled regular expressions in the log buffer
This change keeps each compiled regular expression in a cache in the
log buffer. The cache size is not more than the number of patterns
given to Match.

This change removes the TODO in log_buffer.go.
2026-07-20 16:12:36 -07:00
Ciprian Hacman a20306e6a1 fix(logwatchers/kmsg): don't close the old parser twice when Stop() interrupts a restart
The restart path closes the failed parser before retrying. If stopping
is signaled during the retry wait, watchLoop's deferred cleanup closed
the same parser again, logging a spurious 'file already closed' error
at shutdown. Clear the reference after closing and nil-check the defer.
2026-07-11 10:28:27 +03:00
Ciprian Hacman b77c1eb03f fix(logwatchers/kmsg): don't block Stop() when the log channel is full
The log monitor stops draining logCh before calling watcher.Stop(), so
with a full channel (e.g. a kmsg burst at shutdown) watchLoop blocked
on the send forever, never called tomb.Done(), and Stop() hung.
Select on tomb.Stopping() alongside the send.
2026-07-11 10:27:59 +03:00
Ciprian Hacman 187d4d30d6 fix(logwatchers/kmsg): rate-limit parser restarts to prevent hot loop
If the restarted parser's channel closes again right away (reads keep
failing on the reopened /dev/kmsg), the watcher restarts in a tight
loop with no delay, spinning a CPU core and flooding the logs
(measured 37k restarts in 200ms). Delay the first attempt when the
previous restart was less than retryDelay ago.
2026-07-11 10:27:37 +03:00
Ciprian Hacman 3d516d9213 test(logwatchers/kmsg): inject parser factory for testability and cover restart/stop 2026-04-11 08:37:32 +03:00
Kubernetes Prow RobotandGitHub ea22add87e Merge pull request #1259 from hakman/kmsg-duplicate-message
fix(logwatchers/kmsg): prevent duplicate message replay after restart
2026-04-11 00:18:18 +05:30
Ciprian Hacman b3379b0d23 fix(logwatchers/kmsg): prevent duplicate message replay after restart 2026-04-10 16:06:32 +03:00
Ciprian Hacman 78f76b2778 fix(logwatchers/kmsg): don't close parser from Stop()
Closing the parser in Stop() triggers kmsgparser's read goroutine to
close its output channel, which made watchLoop take the restart path
(added in #1192) during intentional shutdown. Leave parser cleanup to
watchLoop's defer, which is the single owner of the parser lifecycle.
2026-04-10 15:45:22 +03:00
Arjun Raman 748fecd95d Remove opt-in knob for restarting kmsg parser and simplify retry loop 2026-03-24 11:20:14 -07:00
Arjun RamanandGitHub c530d1f701 Remove log message for restart on error
Removed log message for disabled restart on error.
2025-12-18 12:29:26 -08:00
Arjun Raman f1bdf8d30e Restart kmsg on error 2025-12-11 15:51:24 -08:00
Ciprian Hacman 2e69489cc6 Update golangci-lint to v2.6.2 2025-11-29 10:42:18 +02:00
Sergey Kanzhelev 3e64800668 enabled a few more linter rules 2025-09-11 18:47:20 +00:00
Sergey Kanzhelev 0ce333bbc5 enabled and fixed the errcheck linter rule 2025-09-10 21:45:46 +00:00
Sergey Kanzhelev a3a4504706 fix the static ckeck linter issues 2025-09-08 19:10:28 +00:00
Sergey Kanzhelev 75bf501888 format imports 2025-08-13 16:56:32 +00:00
googs1025 f5433f460d feature: add custom message for systemlogmonitor rule 2024-12-23 19:45:29 +08:00
tashen 3a386a659e add skip list to aviod take too much efforts to translate in file log watcher 2024-10-16 10:56:15 +08:00
Ciprian Hacman fdd522a951 Update github.com/coreos/go-systemd to v22.5.0 2023-09-20 07:13:42 +03:00
Ciprian Hacman 65e4aa3c5e Remove dependency on code.cloudfoundry.org/clock 2023-09-19 12:50:29 +03:00
Ciprian Hacman 5210373640 Init useful flags for klog/v2 2023-09-17 11:00:42 +03:00
Manuel RügerandCiprian Hacman e43459d86d Move glog/klog logging to klog/v2 2023-09-17 08:57:33 +03:00
Ciprian Hacman f58f6cd208 Update tests to run also on macOS 2023-09-11 19:25:59 +03:00
Ciprian Hacman 2077606ba3 Remove direct dependency on google/cadvisor 2023-09-08 15:28:25 +03:00
Fan Shang Xiang adbe770d74 replace k8s.io/apimachinery/pkg/util/clock with k8s.io/utils/clock 2023-08-31 06:27:32 +00:00
Kubernetes Prow RobotandGitHub 6b538a5d4e Merge pull request #768 from testwill/pkg-import
chore: pkg imported more than once
2023-06-25 22:07:08 -07:00
Kubernetes Prow RobotandGitHub e6fbdd434a Merge pull request #760 from MartinForReal/master
bump k8s.io dependencies to 1.17.2
2023-06-25 21:41:16 -07:00
guoguangwu da422bb452 chore: pkg imported more than once 2023-06-21 14:14:53 +08:00
guoguangwu 6dc23ca804 chore: remove refs to deprecated io/ioutil 2023-06-21 12:12:27 +08:00
Fan Shang Xiang b5e4ef628b bump k8s.io to 1.17.2 2023-06-12 22:27:39 +08:00
Kubernetes Prow RobotandGitHub 7b6805491c Merge pull request #716 from zendesk/grosser/silence
remove "Start watching journald" to avoid plugin log spam
2023-01-31 23:13:06 -08:00
Michael Grosser a83ef25930 remove "Start watching journald" to avoid plugin log spam 2023-01-31 21:31:31 -08:00
Yordis Prieto Lazo 0842910049 chore: fix misspelling 2022-12-18 22:58:07 -05:00
whwreflux 3fba7a9e86 fix README under systemlogmonitor 2022-07-29 17:14:46 +08:00
a39a7c6e0f Add condition message to event message
If you're using some monitoring solution that aggregates events from
your Kubernetes cluster, having the underlying reason why a condition
triggered could be very useful, especially if you are using custom
plugin monitors.

Co-authored-by: Micah Norman <micnorman@paypal.com>
Signed-off-by: Ryan Eschinger <reschinger@paypal.com>
2022-06-08 21:42:40 +00:00
Jeremy Edwards adc587f222 Support filelog watching in Windows. 2021-01-13 17:16:46 +00:00
Jeremy Edwards 4adec4bbc6 Introduce Windows build of Node Problem Detector 2020-12-05 23:54:52 +00:00
yuzhiquan b458f0d028 fix: modify typo 2019-12-03 15:21:57 +08:00
Lantao Liu be7cc78aa0 Properly close channel when monitor exits.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-10-25 14:11:39 -07:00
wenjun93 4a4ebc7097 avoid log channel closed caused endless loop 2019-10-25 11:43:49 +08:00
Andrew Stribblehill 09c498ad74 Empty LogPath will use journald's default path. 2019-08-27 01:55:30 +02:00
Zhen Wang 182a9450dd Print monitor config path in the logs 2019-07-30 11:00:47 -07:00
Xuewei Zhang 94af7de97b Report metrics from custom-plugin-monitor 2019-07-25 11:28:38 -07:00
Xuewei Zhang fbebcf311b Report metrics from system-log-monitor 2019-07-12 14:38:21 -07:00
Xuewei Zhang a07176073a Add existing monitors into the problem daemon registration hook. 2019-06-13 00:51:17 -07:00
Xuewei Zhang c6c4e80c9d Remove TestGoroutineLeak unit tests.
We are seeing some flakes on these tests because some goroutine
fluctuation:
https://github.com/kubernetes/node-problem-detector/pull/275#issuecomment-499306727

Removing the tests, as it's robust to test leakage in a soak/stress
test, rather than unit test.
2019-06-06 16:27:59 -07:00