forked from TencentBlueKing/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.go
42 lines (37 loc) · 949 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
package status
import (
"encoding/json"
"github.com/elastic/beats/libbeat/common"
s "github.com/elastic/beats/libbeat/common/schema"
c "github.com/elastic/beats/libbeat/common/schema/mapstriface"
)
var (
schema = s.Schema{
"uuid": c.Str("uuid"),
"name": c.Str("name"),
"version": c.Dict("version", s.Schema{
"number": c.Str("number"),
}),
"status": c.Dict("status", s.Schema{
"overall": c.Dict("overall", s.Schema{
"state": c.Str("state"),
}),
}),
"metrics": c.Dict("metrics", s.Schema{
"requests": c.Dict("requests", s.Schema{
"total": c.Int("total"),
"disconnects": c.Int("disconnects"),
}),
"concurrent_connections": c.Int("concurrent_connections"),
}),
}
)
type OverallMetrics struct {
Metrics map[string][][]uint64
}
func eventMapping(content []byte) common.MapStr {
var data map[string]interface{}
json.Unmarshal(content, &data)
event, _ := schema.Apply(data)
return event
}