forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.go
43 lines (36 loc) · 911 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
41
42
43
package cluster_health
import (
"encoding/json"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
)
type Timecheck struct {
RoundStatus string `json:"round_status"`
Epoch int64 `json:"epoch"`
Round int64 `json:"round"`
}
type Output struct {
OverallStatus string `json:"overall_status"`
Timechecks Timecheck `json:"timechecks"`
}
type HealthRequest struct {
Status string `json:"status"`
Output Output `json:"output"`
}
func eventMapping(content []byte) common.MapStr {
var d HealthRequest
err := json.Unmarshal(content, &d)
if err != nil {
logp.Err("Error: ", err)
}
return common.MapStr{
"overall_status": d.Output.OverallStatus,
"timechecks": common.MapStr{
"epoch": d.Output.Timechecks.Epoch,
"round": common.MapStr{
"value": d.Output.Timechecks.Round,
"status": d.Output.Timechecks.RoundStatus,
},
},
}
}