From c3f6bb05e1398ff852bb0724f88a2db05fbb8916 Mon Sep 17 00:00:00 2001 From: kn0wl3dge Date: Sat, 29 Oct 2022 00:05:43 +0200 Subject: [PATCH] fix(elasticsearch): update timestamp format so it is interpreted by elasticsearch --- pkg/track/elk.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/track/elk.go b/pkg/track/elk.go index 21ed743..68af56f 100644 --- a/pkg/track/elk.go +++ b/pkg/track/elk.go @@ -9,7 +9,6 @@ import ( "log" "net" "net/http" - "strconv" "strings" "time" @@ -25,7 +24,7 @@ type Mozi struct { } type ELKMozi struct { - Time string `json:"timestamp"` + Time string `json:"@timestamp"` Config ELKMoziConfig `json:"config"` Node ELKMoziNode `json:"node"` } @@ -75,7 +74,7 @@ func NewELKClient(elkConfig ELKConfig) *ELKClient { } _, err = es.Info() if err != nil { - log.Printf("Error getting response: %s", err) + log.Printf("Error getting response: %s\n", err) return nil } @@ -100,7 +99,7 @@ func NewELKClient(elkConfig ELKConfig) *ELKClient { func createELKMoziDocument(input *Mozi) []byte { data := ELKMozi{ - Time: strconv.FormatInt(time.Now().Unix(), 10), + Time: time.Now().UTC().Format("2006-01-02T15:04:05.123Z"), Config: ELKMoziConfig{ Raw: strings.Trim(string(input.cnf.Rawdata[:]), "\x00"), Version: input.cnf.Version,