diff --git a/src/core/nginx.go b/src/core/nginx.go index 0b8a67e4e..dac9c70c8 100644 --- a/src/core/nginx.go +++ b/src/core/nginx.go @@ -810,18 +810,17 @@ func runtimeFromConfigure(configure []string) []string { // AccessLogs returns a list of access logs in the config func AccessLogs(p *proto.NginxConfig) map[string]string { var found = make(map[string]string) - + name := "" + for _, accessLog := range p.GetAccessLogs().GetAccessLog() { - if accessLog.GetName() == "off" { - continue - } - - if accessLog.GetReadable() { - name := strings.Split(accessLog.GetName(), " ")[0] + name = strings.Split(accessLog.GetName(), " ")[0] + + // check if the access log is readable or not + if accessLog.GetReadable() && accessLog.GetName() != "off" { format := accessLog.GetFormat() found[name] = format - } else { - log.Warnf("NGINX Access log %s is not readable. Please make it readable in order for NGINX metrics to be collected.", accessLog.GetName()) + } else if(!strings.Contains(name, "syslog:")){ + log.Warnf("NGINX Access log %s is not readable or is disabled. Please make it readable and enabled in order for NGINX metrics to be collected.", accessLog.GetName()) } } @@ -831,14 +830,17 @@ func AccessLogs(p *proto.NginxConfig) map[string]string { // ErrorLogs returns a list of error logs in the config func ErrorLogs(p *proto.NginxConfig) map[string]string { var found = make(map[string]string) - + name := "" + for _, errorLog := range p.GetErrorLogs().GetErrorLog() { + name = strings.Split(errorLog.GetName(), " ")[0] + + // check if the error log is readable or not if errorLog.GetReadable() { - name := strings.Split(errorLog.GetName(), " ")[0] // In the future, different error log formats will be supported found[name] = "" - } else { - log.Warnf("NGINX Error log %s is not readable. Please make it readable in order for NGINX metrics to be collected.", errorLog.GetName()) + } else if(!strings.Contains(name, "syslog:")){ + log.Warnf("NGINX Error log %s is not readable or is disabled. Please make it readable and enabled in order for NGINX metrics to be collected.", errorLog.GetName()) } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go index 0b8a67e4e..dac9c70c8 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go @@ -810,18 +810,17 @@ func runtimeFromConfigure(configure []string) []string { // AccessLogs returns a list of access logs in the config func AccessLogs(p *proto.NginxConfig) map[string]string { var found = make(map[string]string) - + name := "" + for _, accessLog := range p.GetAccessLogs().GetAccessLog() { - if accessLog.GetName() == "off" { - continue - } - - if accessLog.GetReadable() { - name := strings.Split(accessLog.GetName(), " ")[0] + name = strings.Split(accessLog.GetName(), " ")[0] + + // check if the access log is readable or not + if accessLog.GetReadable() && accessLog.GetName() != "off" { format := accessLog.GetFormat() found[name] = format - } else { - log.Warnf("NGINX Access log %s is not readable. Please make it readable in order for NGINX metrics to be collected.", accessLog.GetName()) + } else if(!strings.Contains(name, "syslog:")){ + log.Warnf("NGINX Access log %s is not readable or is disabled. Please make it readable and enabled in order for NGINX metrics to be collected.", accessLog.GetName()) } } @@ -831,14 +830,17 @@ func AccessLogs(p *proto.NginxConfig) map[string]string { // ErrorLogs returns a list of error logs in the config func ErrorLogs(p *proto.NginxConfig) map[string]string { var found = make(map[string]string) - + name := "" + for _, errorLog := range p.GetErrorLogs().GetErrorLog() { + name = strings.Split(errorLog.GetName(), " ")[0] + + // check if the error log is readable or not if errorLog.GetReadable() { - name := strings.Split(errorLog.GetName(), " ")[0] // In the future, different error log formats will be supported found[name] = "" - } else { - log.Warnf("NGINX Error log %s is not readable. Please make it readable in order for NGINX metrics to be collected.", errorLog.GetName()) + } else if(!strings.Contains(name, "syslog:")){ + log.Warnf("NGINX Error log %s is not readable or is disabled. Please make it readable and enabled in order for NGINX metrics to be collected.", errorLog.GetName()) } }