|
@@ -136,14 +136,19 @@ func (s *SyslogSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb)
|
|
func (s *SyslogSource) buildLogFromSyslog(ts *time.Time, hostname *string,
|
|
func (s *SyslogSource) buildLogFromSyslog(ts *time.Time, hostname *string,
|
|
appname *string, pid *string, msg *string) (string, error) {
|
|
appname *string, pid *string, msg *string) (string, error) {
|
|
ret := ""
|
|
ret := ""
|
|
|
|
+ if msg == nil {
|
|
|
|
+ return "", errors.Errorf("missing message field in syslog message")
|
|
|
|
+ }
|
|
if ts != nil {
|
|
if ts != nil {
|
|
ret += ts.Format("Jan 2 15:04:05")
|
|
ret += ts.Format("Jan 2 15:04:05")
|
|
} else {
|
|
} else {
|
|
|
|
+ s.logger.Tracef("%s - missing TS", *msg)
|
|
ret += time.Now().Format("Jan 2 15:04:05")
|
|
ret += time.Now().Format("Jan 2 15:04:05")
|
|
}
|
|
}
|
|
if hostname != nil {
|
|
if hostname != nil {
|
|
ret += " " + *hostname
|
|
ret += " " + *hostname
|
|
} else {
|
|
} else {
|
|
|
|
+ s.logger.Tracef("%s - missing host", *msg)
|
|
ret += " unknownhost"
|
|
ret += " unknownhost"
|
|
}
|
|
}
|
|
if appname != nil {
|
|
if appname != nil {
|
|
@@ -169,8 +174,6 @@ func (s *SyslogSource) buildLogFromSyslog(ts *time.Time, hostname *string,
|
|
}
|
|
}
|
|
if msg != nil {
|
|
if msg != nil {
|
|
ret += *msg
|
|
ret += *msg
|
|
- } else {
|
|
|
|
- return "", errors.Errorf("missing message field in syslog message")
|
|
|
|
}
|
|
}
|
|
return ret, nil
|
|
return ret, nil
|
|
|
|
|
|
@@ -194,6 +197,7 @@ func (s *SyslogSource) handleSyslogMsg(out chan types.Event, t *tomb.Tomb, c cha
|
|
var ts time.Time
|
|
var ts time.Time
|
|
|
|
|
|
logger := s.logger.WithField("client", syslogLine.Client)
|
|
logger := s.logger.WithField("client", syslogLine.Client)
|
|
|
|
+ logger.Tracef("raw: %s", syslogLine)
|
|
linesReceived.With(prometheus.Labels{"source": syslogLine.Client}).Inc()
|
|
linesReceived.With(prometheus.Labels{"source": syslogLine.Client}).Inc()
|
|
p := rfc5424.NewParser()
|
|
p := rfc5424.NewParser()
|
|
m, err := p.Parse(syslogLine.Message)
|
|
m, err := p.Parse(syslogLine.Message)
|