1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
data.go 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
package bucket
import (
"encoding/json"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
)
type BucketQuota struct {
RAM int64 `json:"ram"`
RawRAM int64 `json:"rawRAM"`
}
type BucketBasicStats struct {
QuotaPercentUsed float64 `json:"quotaPercentUsed"`
OpsPerSec int64 `json:"opsPerSec"`
DiskFetches int64 `json:"diskFetches"`
ItemCount int64 `json:"itemCount"`
DiskUsed int64 `json:"diskUsed"`
DataUsed int64 `json:"dataUsed"`
MemUsed int64 `json:"memUsed"`
}
type Buckets []struct {
Name string `json:"name"`
BucketType string `json:"bucketType"`
Quota BucketQuota `json:"quota"`
BasicStats BucketBasicStats `json:"basicStats"`
}
func eventsMapping(content []byte) []common.MapStr {
var d Buckets
err := json.Unmarshal(content, &d)
if err != nil {
logp.Err("Error: ", err)
}
events := []common.MapStr{}
for _, Bucket := range d {
event := common.MapStr{
"name": Bucket.Name,
"type": Bucket.BucketType,
"data": common.MapStr{
"used": common.MapStr{
"bytes": Bucket.BasicStats.DataUsed,
},
},
"disk": common.MapStr{
"fetches": Bucket.BasicStats.DiskFetches,
"used": common.MapStr{
"bytes": Bucket.BasicStats.DiskUsed,
},
},
"memory": common.MapStr{
"used": common.MapStr{
"bytes": Bucket.BasicStats.MemUsed,
},
},
"quota": common.MapStr{
"ram": common.MapStr{
"bytes": Bucket.Quota.RAM,
},
"use": common.MapStr{
"pct": Bucket.BasicStats.QuotaPercentUsed,
},
},
"ops_per_sec": Bucket.BasicStats.OpsPerSec,
"item_count": Bucket.BasicStats.ItemCount,
}
events = append(events, event)
}
return events
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v5.6.7

搜索帮助

0d507c66 1850385 C8b1a773 1850385