From 2cf0699ad4fd2713c461b76e7cbefcb99a38e011 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Mon, 1 Sep 2025 17:06:13 +0200 Subject: [PATCH] feat(service_monitor): add more information to parsing of transfer-job-manager logs --- build.sh | 2 +- service_monitor.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 5a914fb..3cebecf 100755 --- a/build.sh +++ b/build.sh @@ -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/ diff --git a/service_monitor.go b/service_monitor.go index 2e07dd4..470479a 100644 --- a/service_monitor.go +++ b/service_monitor.go @@ -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 }