feat(service_monitor): add more information to parsing of transfer-job-manager logs

This commit is contained in:
Patryk Hegenberg 2025-09-01 17:06:13 +02:00
parent 92b5d98465
commit 2cf0699ad4
2 changed files with 37 additions and 1 deletions

View file

@ -13,7 +13,7 @@ if [ -d "${PACKAGE_NAME}" ]; then
rm -rf "${PACKAGE_NAME:?}"
fi
CGO_ENABLED=0 go build -ldflags="-s -w" -o "$PACKAGE_DIR"/tixel-watch .
CGO_ENABLED=0 go build -ldflags="-s -w" -o "$PACKAGE_DIR"/tixel-watch -buildvcs .
cp -r ./tixel-watch.service $PACKAGE_DIR/
cp -r ./configs/ $PACKAGE_DIR/

View file

@ -302,6 +302,42 @@ func parseTJMService(entry LogEntry) LogEntry {
newEntry.Fields["message_time"] = timestampTime
newEntry.Fields["message"] = strings.Join(info, " ")
if info != nil {
tmpInfo := strings.ReplaceAll(strings.Join(info, " "), "[ ]", "[]")
tmpSplit := strings.Fields(tmpInfo)
var transferDirection string
var logMessage string
username := tmpSplit[2]
correlationID := tmpSplit[1]
threadID := tmpSplit[3]
javaClass := tmpSplit[4]
if len(tmpSplit) > 6 && strings.Contains(tmpSplit[6], "-out") {
transferDirection = "outgoing"
logMessage = strings.Join(tmpSplit[7:], " ")
} else if len(tmpSplit) > 6 && strings.Contains(tmpSplit[6], "-in") {
transferDirection = "incoming"
logMessage = strings.Join(tmpSplit[7:], " ")
} else {
logMessage = strings.Join(tmpSplit[6:], " ")
}
if username != "" && username != "[]" {
newEntry.Fields["username"] = username
}
if correlationID != "" {
newEntry.Fields["correlation_id"] = correlationID
}
if threadID != "" {
newEntry.Fields["thread_id"] = threadID
}
if javaClass != "" {
newEntry.Fields["java_class"] = javaClass
}
if transferDirection != "" {
newEntry.Fields["transfer_direction"] = transferDirection
}
newEntry.Fields["log_message"] = logMessage
}
return newEntry
}