diff --git a/src/plugins/nginx.go b/src/plugins/nginx.go index 679878b890..9e12c60057 100644 --- a/src/plugins/nginx.go +++ b/src/plugins/nginx.go @@ -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 @@ -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 } diff --git a/src/plugins/nginx_test.go b/src/plugins/nginx_test.go index bdcd75b13f..3e73fc4376 100644 --- a/src/plugins/nginx_test.go +++ b/src/plugins/nginx_test.go @@ -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 { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx.go index 679878b890..9e12c60057 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx.go @@ -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 @@ -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 }