Skip to content

Allowlist Error Messages #907

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

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/plugins/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ var (
re.MustCompile(`.*\[alert\].*`),
re.MustCompile(`.*\[crit\].*`),
}
warningRegex = re.MustCompile(`.*\[warn\].*`)
warningRegex = re.MustCompile(`.*\[warn\].*`)
ignoreErrorList = re.MustCompile(`.*(usage report| license expired).*`)
)

// Nginx is the metadata of our nginx binary
Expand Down Expand Up @@ -619,13 +620,13 @@ func (n *Nginx) tailLog(logFile string, errorChannel chan string) {
for {
select {
case d := <-data:
if warningRegex.MatchString(d) && n.config.Nginx.TreatWarningsAsErrors {
if warningRegex.MatchString(d) && n.config.Nginx.TreatWarningsAsErrors && !ignoreErrorList.MatchString(d) {
errorChannel <- d
return
}

for _, errorRegex := range reloadErrorList {
if errorRegex.MatchString(d) {
if errorRegex.MatchString(d) && !ignoreErrorList.MatchString(d) {
errorChannel <- d
return
}
Expand Down
18 changes: 18 additions & 0 deletions src/plugins/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,24 @@ func TestNginx_monitorLog(t *testing.T) {
treatWarningsAsErrors: false,
expected: "",
},
{
name: "ignore error log: usage report ",
errorLog: "2025/06/25 15:08:04 [error] 123456#123456: certificate verify error: (10:certificate has expired) during usage report",
treatWarningsAsErrors: false,
expected: "",
},
{
name: "ignore error log: license expired ",
errorLog: "2025/06/25 15:07:24 [alert] 123456#123456: license expired; the grace period will end in 71 days",
treatWarningsAsErrors: false,
expected: "",
},
{
name: "ignore error log: usaage report 400",
errorLog: "2024/12/25 15:00:04 [error] 123456#123456: server returned 400 during usage report",
treatWarningsAsErrors: false,
expected: "",
},
}

for _, test := range tests {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading