I very much appreciate the great work that was done in a2f9eb8 per #209 to decorate the container logs from ktranslate with the logtype of ktranslate-health however I was seeing situations where sometimes the logs were decorated (and hence nicely parsed) while other times they weren't.
For example, in New Relic:
SELECT `container_service`,`plugin.type`,`severity`,`message` FROM Log WHERE `collector.name` = 'ktranslate' AND `device_name` IS NULL
(notice the first two are decorated, while the last two aren't)
After lots of searching through code and debugging, I think the problem is that the logtype attribute is set as a Common.Attribute (applying to the entire batch) and it's only set if NONE of the logs in the batch being sent are a syslog. However, in the situation where at least one log in the batch IS a syslog, the container logs aren't properly decorated and hence aren't parsed :-(
|
if !hasSyslog { |
|
ls.Common.Attributes["plugin.type"] = kt.PluginHealth |
|
ls.Common.Attributes["logtype"] = "ktranslate-health" |
|
} |
Would it make sense to never mix syslogs and non-syslogs in the same batch since they have to share the Common.Attribute?
Maybe in the code below (which is already copying each log to a new logset) create a syslog_logset and a non_syslog_logset...then send them independently, with the latter getting the logtype of ktranslate-health?
|
for i, l := range logs { |
|
ls.Logs[i] = log{ |
|
Timestamp: ts, |
|
Message: l, |
|
} |
|
if !hasSyslog && strings.Contains(l, kt.PluginSyslog) { |
I very much appreciate the great work that was done in a2f9eb8 per #209 to decorate the container logs from ktranslate with the
logtypeofktranslate-healthhowever I was seeing situations where sometimes the logs were decorated (and hence nicely parsed) while other times they weren't.For example, in New Relic:
SELECT `container_service`,`plugin.type`,`severity`,`message` FROM Log WHERE `collector.name` = 'ktranslate' AND `device_name` IS NULL(notice the first two are decorated, while the last two aren't)
After lots of searching through code and debugging, I think the problem is that the
logtypeattribute is set as aCommon.Attribute(applying to the entire batch) and it's only set if NONE of the logs in the batch being sent are asyslog. However, in the situation where at least one log in the batch IS a syslog, the container logs aren't properly decorated and hence aren't parsed :-(ktranslate/pkg/sinks/nr/nr.go
Lines 400 to 403 in f18e227
Would it make sense to never mix syslogs and non-syslogs in the same batch since they have to share the
Common.Attribute?Maybe in the code below (which is already copying each log to a new logset) create a syslog_logset and a non_syslog_logset...then send them independently, with the latter getting the
logtypeofktranslate-health?ktranslate/pkg/sinks/nr/nr.go
Lines 391 to 396 in f18e227