forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata.go
40 lines (33 loc) · 854 Bytes
/
data.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
38
39
40
package leader
import (
"encoding/json"
"github.com/elastic/beats/libbeat/common"
)
type Counts struct {
Success int64 `json:"success"`
Fail int64 `json:"fail"`
}
type Latency struct {
Average float64 `json:"average"`
Current float64 `json:"current"`
Maximum float64 `json:"maximum"`
Minimum int64 `json:"minimum"`
StandardDeviation float64 `json:"standardDeviation"`
}
type FollowersID struct {
Latency Latency `json:"latency"`
Counts Counts `json:"counts"`
}
type Leader struct {
Followers map[string]FollowersID `json:"followers"`
Leader string `json:"leader"`
}
func eventMapping(content []byte) common.MapStr {
var data Leader
json.Unmarshal(content, &data)
event := common.MapStr{
"followers": data.Followers,
"leader": data.Leader,
}
return event
}