feat: implement drain3 based generic log-parser

This commit is contained in:
Patryk Hegenberg 2026-01-18 16:51:44 +01:00
parent 1d1568e3ee
commit 5af49f926a
17 changed files with 612 additions and 220 deletions

View file

@ -265,6 +265,7 @@ func (ws *WebService) handleServiceStats(w http.ResponseWriter, r *http.Request)
http.Error(w, fmt.Sprintf("Query error: %v", err), http.StatusInternalServerError)
return
}
uniqueTransfersTotal := make(map[string]struct{})
uniqueTransfersIncoming := make(map[string]struct{})
uniqueTransfersOutgoing := make(map[string]struct{})
@ -274,35 +275,62 @@ func (ws *WebService) handleServiceStats(w http.ResponseWriter, r *http.Request)
var identifier string
var direction string
switch v := entry.ServiceInformation.(type) {
case models.TSTransferInfo:
identifier = v.TransferID
direction = v.Direction
case *models.TSTransferInfo:
identifier = v.TransferID
direction = v.Direction
case models.TJMTransferInfo:
identifier = v.TransferID
direction = v.Direction
case *models.TJMTransferInfo:
identifier = v.TransferID
direction = v.Direction
case map[string]any:
identifier, _ = v["transfer_identifier"].(string)
direction, _ = v["direction"].(string)
default:
continue
if entry.Fields != nil {
if id, ok := entry.Fields["transfer_id"].(string); ok {
identifier = id
} else if id, ok := entry.Fields["correlation_id"].(string); ok {
identifier = id
}
if dir, ok := entry.Fields["direction"].(string); ok {
direction = dir
} else if rawName, ok := entry.Fields["transfer_name_raw"].(string); ok {
if strings.Contains(rawName, "-in") {
direction = "incoming"
} else if strings.Contains(rawName, "-out") {
direction = "outgoing"
}
}
if direction == "" && entry.Service == "tixstream" {
if strings.HasPrefix(entry.Raw, "in:") {
direction = "incoming"
} else if strings.HasPrefix(entry.Raw, "out:") {
direction = "outgoing"
}
}
}
if identifier != "" {
if identifier == "" && entry.ServiceInformation != nil {
switch v := entry.ServiceInformation.(type) {
case models.TSTransferInfo:
identifier = v.TransferID
direction = v.Direction
case *models.TSTransferInfo:
identifier = v.TransferID
direction = v.Direction
case models.TJMTransferInfo:
identifier = v.TransferID
direction = v.Direction
case *models.TJMTransferInfo:
identifier = v.TransferID
direction = v.Direction
case map[string]any:
identifier, _ = v["transfer_identifier"].(string)
direction, _ = v["direction"].(string)
}
}
if identifier != "" && identifier != "no_transfer_id" {
uniqueTransfersTotal[identifier] = struct{}{}
switch strings.ToLower(direction) {
case "incoming":
uniqueTransfersIncoming[identifier] = struct{}{}
case "outgoing":
dirLower := strings.ToLower(direction)
if strings.Contains(dirLower, "outgoing") || strings.Contains(dirLower, "out") {
uniqueTransfersOutgoing[identifier] = struct{}{}
default:
} else if strings.Contains(dirLower, "incoming") || strings.Contains(dirLower, "in") {
uniqueTransfersIncoming[identifier] = struct{}{}
} else {
uniqueTransfersNil[identifier] = struct{}{}
}
}