1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
data.go 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
package system
import (
"encoding/json"
"fmt"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/module/kubernetes"
)
func eventMapping(content []byte) ([]common.MapStr, error) {
events := []common.MapStr{}
var summary kubernetes.Summary
err := json.Unmarshal(content, &summary)
if err != nil {
return nil, fmt.Errorf("Cannot unmarshal json response: %s", err)
}
node := summary.Node
for _, syscontainer := range node.SystemContainers {
containerEvent := common.MapStr{
mb.ModuleDataKey: common.MapStr{
"node": common.MapStr{
"name": node.NodeName,
},
},
"container": syscontainer.Name,
"start_time": syscontainer.StartTime,
"cpu": common.MapStr{
"usage": common.MapStr{
"nanocores": syscontainer.CPU.UsageNanoCores,
"core": common.MapStr{
"ns": syscontainer.CPU.UsageCoreNanoSeconds,
},
},
},
"memory": common.MapStr{
"usage": common.MapStr{
"bytes": syscontainer.Memory.UsageBytes,
},
"workingset": common.MapStr{
"bytes": syscontainer.Memory.WorkingSetBytes,
},
"rss": common.MapStr{
"bytes": syscontainer.Memory.RssBytes,
},
"pagefaults": syscontainer.Memory.PageFaults,
"majorpagefaults": syscontainer.Memory.MajorPageFaults,
},
}
events = append(events, containerEvent)
}
return events, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.2.1

搜索帮助