From 17f62b6495239c025459527ac08ad2db9ec6b083 Mon Sep 17 00:00:00 2001 From: pb Date: Mon, 5 Aug 2024 15:47:53 +0200 Subject: [PATCH] add labels to lokiwritter after initialisation --- logs/lokiwriter.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/logs/lokiwriter.go b/logs/lokiwriter.go index 1cb004b..4df2224 100644 --- a/logs/lokiwriter.go +++ b/logs/lokiwriter.go @@ -55,6 +55,15 @@ func (w *LokiWriter) Write(p []byte) (n int, err error) { } labels["level"] = level + // Add label that have been added to the event + + for k,v := range(event){ + if k != "level" && k != "time" && k != "message"{ + data := v.(map[string]string) + labels[k] = data["data"] + } + } + // Format the timestamp in nanoseconds timestamp := fmt.Sprintf("%d000000", time.Now().UnixNano()/int64(time.Millisecond))