forked from TencentBlueKing/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.go
40 lines (36 loc) · 909 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 cpu
import (
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/metricbeat/mb"
)
func eventsMapping(cpuStatsList []CPUStats) []common.MapStr {
events := []common.MapStr{}
for _, cpuStats := range cpuStatsList {
events = append(events, eventMapping(&cpuStats))
}
return events
}
func eventMapping(stats *CPUStats) common.MapStr {
event := common.MapStr{
mb.ModuleData: common.MapStr{
"container": stats.Container.ToMapStr(),
},
"core": stats.PerCpuUsage,
"total": common.MapStr{
"pct": stats.TotalUsage,
},
"kernel": common.MapStr{
"ticks": stats.UsageInKernelmode,
"pct": stats.UsageInKernelmodePercentage,
},
"user": common.MapStr{
"ticks": stats.UsageInUsermode,
"pct": stats.UsageInUsermodePercentage,
},
"system": common.MapStr{
"ticks": stats.SystemUsage,
"pct": stats.SystemUsagePercentage,
},
}
return event
}