feat(service-monitor): simplify parse functions for tjm and tixstream
This commit is contained in:
parent
2cf0699ad4
commit
a79087886f
1 changed files with 39 additions and 82 deletions
|
|
@ -222,58 +222,35 @@ func parseTixstreamService(entry LogEntry) LogEntry {
|
|||
return newEntry
|
||||
}
|
||||
|
||||
logLevel := parts[0]
|
||||
timestampDate := parts[1]
|
||||
timestampTime := parts[2]
|
||||
transferID := parts[3]
|
||||
info := parts[4:]
|
||||
|
||||
if newEntry.Fields == nil {
|
||||
newEntry.Fields = make(map[string]any)
|
||||
}
|
||||
newEntry.Fields["log_level"] = logLevel
|
||||
newEntry.Fields["message_date"] = timestampDate
|
||||
newEntry.Fields["message_time"] = timestampTime
|
||||
newEntry.Fields["transfer_id"] = transferID
|
||||
newEntry.Fields["log_level"] = parts[0]
|
||||
newEntry.Fields["message_date"] = parts[1]
|
||||
newEntry.Fields["message_time"] = parts[2]
|
||||
newEntry.Fields["transfer_id"] = parts[3]
|
||||
newEntry.Fields["log_message"] = strings.Join(info, " ")
|
||||
|
||||
if info != nil {
|
||||
var transferDirection string
|
||||
var transferInfo []string
|
||||
var queueStats []string
|
||||
var logType string
|
||||
switch info[0] {
|
||||
case "in:":
|
||||
logType = "direction_info"
|
||||
transferDirection = "incoming"
|
||||
transferInfo = info[1:]
|
||||
case "out:":
|
||||
logType = "direction_info"
|
||||
transferDirection = "outgoing"
|
||||
transferInfo = info[1:]
|
||||
case "queue-stats:":
|
||||
logType = "queue_stats"
|
||||
queueStats = info[1:]
|
||||
case "transfer:":
|
||||
logType = "transfer_info"
|
||||
transferInfo = info[1:]
|
||||
default:
|
||||
logType = "log_message"
|
||||
transferDirection = ""
|
||||
transferInfo = info
|
||||
}
|
||||
if logType != "" {
|
||||
newEntry.Fields["log_type"] = logType
|
||||
}
|
||||
if transferDirection != "" {
|
||||
newEntry.Fields["transfer_direction"] = transferDirection
|
||||
}
|
||||
if transferInfo != nil {
|
||||
newEntry.Fields["transfer_info"] = strings.Join(transferInfo, ";")
|
||||
}
|
||||
if queueStats != nil {
|
||||
newEntry.Fields["queue_stats"] = strings.Join(queueStats, ";")
|
||||
}
|
||||
switch info[0] {
|
||||
case "in:":
|
||||
newEntry.Fields["log_type"] = "direction_info"
|
||||
newEntry.Fields["transfer_direction"] = "incoming"
|
||||
newEntry.Fields["transfer_info"] = strings.Join(info[1:], " ")
|
||||
case "out:":
|
||||
newEntry.Fields["log_type"] = "direction_info"
|
||||
newEntry.Fields["transfer_direction"] = "outgoing"
|
||||
newEntry.Fields["transfer_info"] = strings.Join(info[1:], " ")
|
||||
case "queue-stats:":
|
||||
newEntry.Fields["log_type"] = "queue-stats"
|
||||
newEntry.Fields["queue-stats"] = strings.Join(info[1:], " ")
|
||||
case "transfer:":
|
||||
newEntry.Fields["log_type"] = "transfer_info"
|
||||
newEntry.Fields["transfer_info"] = strings.Join(info[1:], " ")
|
||||
default:
|
||||
newEntry.Fields["log_type"] = "log_message"
|
||||
newEntry.Fields["transfer_info"] = info
|
||||
}
|
||||
|
||||
return newEntry
|
||||
|
|
@ -281,7 +258,8 @@ func parseTixstreamService(entry LogEntry) LogEntry {
|
|||
|
||||
func parseTJMService(entry LogEntry) LogEntry {
|
||||
newEntry := entry
|
||||
msg := strings.ReplaceAll(entry.Message, " ", " ")
|
||||
msg := strings.TrimSpace(entry.Message)
|
||||
msg = strings.ReplaceAll(msg, " ", " ")
|
||||
msg = strings.ReplaceAll(msg, "---", "")
|
||||
msg = strings.ReplaceAll(msg, " ", " ")
|
||||
parts := strings.Fields(msg)
|
||||
|
|
@ -289,53 +267,32 @@ func parseTJMService(entry LogEntry) LogEntry {
|
|||
return newEntry
|
||||
}
|
||||
|
||||
timestampDate := parts[0]
|
||||
timestampTime := parts[1]
|
||||
logLevel := parts[2]
|
||||
info := parts[3:]
|
||||
|
||||
if newEntry.Fields == nil {
|
||||
newEntry.Fields = make(map[string]any)
|
||||
}
|
||||
newEntry.Fields["log_level"] = logLevel
|
||||
newEntry.Fields["message_date"] = timestampDate
|
||||
newEntry.Fields["message_time"] = timestampTime
|
||||
newEntry.Fields["log_level"] = parts[2]
|
||||
newEntry.Fields["message_date"] = parts[0]
|
||||
newEntry.Fields["message_time"] = parts[1]
|
||||
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]
|
||||
tmpInfo := strings.ReplaceAll(strings.Join(info, " "), "[ ]", "[]")
|
||||
tmpSplit := strings.Fields(tmpInfo)
|
||||
if len(tmpSplit) > 4 {
|
||||
newEntry.Fields["username"] = tmpSplit[2]
|
||||
newEntry.Fields["correlation_id"] = tmpSplit[1]
|
||||
newEntry.Fields["thread_id"] = tmpSplit[3]
|
||||
newEntry.Fields["java_class"] = tmpSplit[4]
|
||||
if len(tmpSplit) > 6 && strings.Contains(tmpSplit[6], "-out") {
|
||||
transferDirection = "outgoing"
|
||||
logMessage = strings.Join(tmpSplit[7:], " ")
|
||||
newEntry.Fields["transfer_direction"] = "outgoing"
|
||||
newEntry.Fields["log_message"] = strings.Join(tmpSplit[7:], " ")
|
||||
} else if len(tmpSplit) > 6 && strings.Contains(tmpSplit[6], "-in") {
|
||||
transferDirection = "incoming"
|
||||
logMessage = strings.Join(tmpSplit[7:], " ")
|
||||
newEntry.Fields["transfer_direction"] = "incoming"
|
||||
newEntry.Fields["log_message"] = strings.Join(tmpSplit[7:], " ")
|
||||
} else {
|
||||
logMessage = strings.Join(tmpSplit[6:], " ")
|
||||
newEntry.Fields["log_message"] = 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue