Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Commit 6af21b0

Browse files
authored
Merge pull request #288 from soubhagya-pradhan/main
Fix wrapped message field ApplicationInstance and Server Name
2 parents d4fc41c + d36a06a commit 6af21b0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

queue/deliverer.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ var (
3030

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

33-
defaultInvalidCharacters = "$&+,:;=?@#|<>()[]"
34-
applicationNameInvalidCharacters = "$&+,;=?@#|<>()[]"
35-
applicationInstanceInvalidCharacters = "[&+;?@|<>()[]"
36-
eventIDInvalidCharacters = "&+,:;=?@#|<>()[]"
37-
otherNameInvalidCharacters = "&+,;=?@#|<>()[]"
38-
originatingUsersInvalidCharacters = "$&+;=?@#|<>()[]"
39-
versionInvalidCharacters = "&+;=?@|<>()[]"
33+
defaultInvalidCharacters = "$&+,:;=?@#|<>()[]"
34+
applicationNameInvalidCharacters = "$&+,;=?@#|<>()[]"
35+
eventIDInvalidCharacters = "&+,:;=?@#|<>()[]"
36+
otherNameInvalidCharacters = "&+,;=?@#|<>()[]"
37+
originatingUsersInvalidCharacters = "$&+;=?@#|<>()[]"
38+
versionInvalidCharacters = "&+;=?@|<>()[]"
4039

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

335334
// ApplicationInstance
336335
lm.ApplicationInstance = "logproxy"
337-
if h := msg.Hostname(); h != nil {
336+
if h := msg.Appname(); h != nil {
338337
lm.ApplicationInstance = *h
339338
}
340339

@@ -344,7 +343,12 @@ func wrapResource(originatingUser string, msg syslog.Message) logging.Resource {
344343
// ServerName
345344
lm.ServerName = "logproxy"
346345
if s := msg.Hostname(); s != nil {
347-
lm.ServerName = *s
346+
comps := strings.Split(*s, ".")
347+
if len(comps) == 3 {
348+
lm.ServerName = comps[0] + "." + comps[1]
349+
} else {
350+
lm.ServerName = *s
351+
}
348352
}
349353

350354
// Severity
@@ -382,8 +386,6 @@ func parseProcID(msg syslog.Message, lm *logging.Resource) {
382386
lm.LogTime = rtrTime.Format(logging.TimeFormat)
383387
}
384388
}
385-
} else {
386-
lm.ApplicationInstance = EncodeString(*procID, applicationInstanceInvalidCharacters)
387389
}
388390
}
389391
}

0 commit comments

Comments
 (0)