forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
37 lines (32 loc) · 878 Bytes
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package json
import (
"time"
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
)
// Event describes the event structure for events
// (in-)directly send to logstash
type event struct {
Timestamp time.Time `struct:"@timestamp"`
Meta meta `struct:"@metadata"`
Fields common.MapStr `struct:",inline"`
}
// Meta defines common event metadata to be stored in '@metadata'
type meta struct {
Beat string `struct:"beat"`
Type string `struct:"type"`
Version string `struct:"version"`
Fields map[string]interface{} `struct:",inline"`
}
func makeEvent(index, version string, in *beat.Event) event {
return event{
Timestamp: in.Timestamp,
Meta: meta{
Beat: index,
Version: version,
Type: "doc",
Fields: in.Meta,
},
Fields: in.Fields,
}
}