Skip to content

Commit

Permalink
error_log, access_log tackle syslog (#185) (#302)
Browse files Browse the repository at this point in the history
* error_log, access_log tackle syslog (#185)
* Some stylistic update (#185) 
* fixed deps and linting

---------

Co-authored-by: Oliver O'Mahony <[email protected]>
  • Loading branch information
Retssaze and oliveromahony authored Jun 9, 2023
1 parent 2b9f2a7 commit bdfb7c8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
28 changes: 15 additions & 13 deletions src/core/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand All @@ -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())
}
}

Expand Down

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

0 comments on commit bdfb7c8

Please sign in to comment.