1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
data.go 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
Berfin Sarı 提交于 2017-10-17 14:46 . Add etcd module (#4970) (#5176)
package self
import (
"encoding/json"
"github.com/elastic/beats/libbeat/common"
)
type LeaderInfo struct {
Leader string `json:"leader"`
StartTime string `json:"startTime"`
Uptime string `json:"uptime"`
}
type AppendRequest struct {
Count int64 `json:"recvAppendRequestCnt"`
}
type Recv struct {
Appendrequest AppendRequest
Bandwithrate float64 `json:"recvBandwithRate"`
Pkgrate float64 `json:"recvPkgRate"`
}
type sendAppendRequest struct {
Cnt int64 `json:"sendAppendRequestCnt"`
}
type Send struct {
AppendRequest sendAppendRequest
BandwithRate float64 `json:"sendBandwidthRate"`
PkgRate float64 `json:"sendPkgRate"`
}
type Self struct {
ID string `json:"id"`
LeaderInfo LeaderInfo
Name string `json:"name"`
Recv Recv
Send Send
StartTime string `json:"startTime"`
State string `json:"state"`
}
func eventMapping(content []byte) common.MapStr {
var data Self
json.Unmarshal(content, &data)
event := common.MapStr{
"id": data.ID,
"leaderinfo": common.MapStr{
"leader": data.LeaderInfo.Leader,
"starttime": data.LeaderInfo.StartTime,
"uptime": data.LeaderInfo.Uptime,
},
"name": data.Name,
"recv": common.MapStr{
"appendrequest": common.MapStr{
"count": data.Recv.Appendrequest.Count,
},
"bandwithrate": data.Recv.Bandwithrate,
"pkgrate": data.Recv.Pkgrate,
},
"send": common.MapStr{
"appendrequest": common.MapStr{
"count": data.Send.AppendRequest.Cnt,
},
"bandwithrate": data.Send.BandwithRate,
"pkgrate": data.Send.PkgRate,
},
"starttime": data.StartTime,
"state": data.State,
}
return event
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.1.2

搜索帮助

0d507c66 1850385 C8b1a773 1850385