Skip to content

Commit

Permalink
fix(elasticsearch): update timestamp format so it is interpreted by e…
Browse files Browse the repository at this point in the history
…lasticsearch
  • Loading branch information
kn0wl3dge committed Oct 28, 2022
1 parent 5cb5463 commit c3f6bb0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/track/elk.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"log"
"net"
"net/http"
"strconv"
"strings"
"time"

Expand All @@ -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"`
}
Expand Down Expand Up @@ -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
}

Expand All @@ -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,
Expand Down

0 comments on commit c3f6bb0

Please sign in to comment.