Skip to content
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

error_log, access_log tackle syslog (#185) #302

Merged
merged 5 commits into from
Jun 9, 2023
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
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.