Skip to content

Commit

Permalink
Merge pull request #288 from soubhagya-pradhan/main
Browse files Browse the repository at this point in the history
Fix wrapped message field ApplicationInstance and Server Name
  • Loading branch information
loafoe authored Nov 29, 2022
2 parents d4fc41c + d36a06a commit 6af21b0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions queue/deliverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ var (

errNoMessage = errors.New("no message in syslogMessage")

defaultInvalidCharacters = "$&+,:;=?@#|<>()[]"
applicationNameInvalidCharacters = "$&+,;=?@#|<>()[]"
applicationInstanceInvalidCharacters = "[&+;?@|<>()[]"
eventIDInvalidCharacters = "&+,:;=?@#|<>()[]"
otherNameInvalidCharacters = "&+,;=?@#|<>()[]"
originatingUsersInvalidCharacters = "$&+;=?@#|<>()[]"
versionInvalidCharacters = "&+;=?@|<>()[]"
defaultInvalidCharacters = "$&+,:;=?@#|<>()[]"
applicationNameInvalidCharacters = "$&+,;=?@#|<>()[]"
eventIDInvalidCharacters = "&+,:;=?@#|<>()[]"
otherNameInvalidCharacters = "&+,;=?@#|<>()[]"
originatingUsersInvalidCharacters = "$&+;=?@#|<>()[]"
versionInvalidCharacters = "&+;=?@|<>()[]"

parser = rfc5424.NewParser()
)
Expand Down Expand Up @@ -334,7 +333,7 @@ func wrapResource(originatingUser string, msg syslog.Message) logging.Resource {

// ApplicationInstance
lm.ApplicationInstance = "logproxy"
if h := msg.Hostname(); h != nil {
if h := msg.Appname(); h != nil {
lm.ApplicationInstance = *h
}

Expand All @@ -344,7 +343,12 @@ func wrapResource(originatingUser string, msg syslog.Message) logging.Resource {
// ServerName
lm.ServerName = "logproxy"
if s := msg.Hostname(); s != nil {
lm.ServerName = *s
comps := strings.Split(*s, ".")
if len(comps) == 3 {
lm.ServerName = comps[0] + "." + comps[1]
} else {
lm.ServerName = *s
}
}

// Severity
Expand Down Expand Up @@ -382,8 +386,6 @@ func parseProcID(msg syslog.Message, lm *logging.Resource) {
lm.LogTime = rtrTime.Format(logging.TimeFormat)
}
}
} else {
lm.ApplicationInstance = EncodeString(*procID, applicationInstanceInvalidCharacters)
}
}
}

0 comments on commit 6af21b0

Please sign in to comment.