mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
feat(host): add interface meta tags of netio metrics (#20780)
This commit is contained in:
@@ -415,6 +415,10 @@ func (d *GuestMetrics) toVmTelegrafData(tagStr string) []string {
|
||||
res = append(res, fmt.Sprintf("%s,%s %s", "vm_mem", tagStr, d.mapToStatStr(d.VmMem.ToMap())))
|
||||
res = append(res, fmt.Sprintf("%s,%s %s", "vm_diskio", tagStr, d.mapToStatStr(d.VmDiskio.ToMap())))
|
||||
for i := range d.VmNetio {
|
||||
netTagMap := d.VmNetio[i].ToTag()
|
||||
for k, v := range netTagMap {
|
||||
tagStr = fmt.Sprintf("%s,%s=%s", tagStr, k, v)
|
||||
}
|
||||
res = append(res, fmt.Sprintf("%s,%s %s", "vm_netio", tagStr, d.mapToStatStr(d.VmNetio[i].ToMap())))
|
||||
}
|
||||
return res
|
||||
@@ -711,6 +715,7 @@ func (m *SGuestMonitor) Netio() []*NetIOMetric {
|
||||
}
|
||||
data.Meta.Ip = ip
|
||||
data.Meta.Index = i
|
||||
data.Meta.Mac = nic.Mac
|
||||
data.Meta.Ifname = ifname
|
||||
data.Meta.NetId = nic.NetId
|
||||
data.Meta.Uptime, _ = host.Uptime()
|
||||
@@ -778,9 +783,19 @@ func (n *NetIOMetric) ToMap() map[string]interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
func (n *NetIOMetric) ToTag() map[string]string {
|
||||
return map[string]string{
|
||||
"interface": fmt.Sprintf("eth%d", n.Meta.Index),
|
||||
"host_interface": n.Meta.Ifname,
|
||||
"mac": n.Meta.Mac,
|
||||
"ip": n.Meta.Ip,
|
||||
}
|
||||
}
|
||||
|
||||
type NetMeta struct {
|
||||
IpType string `json:"ip_type"`
|
||||
Ip string `json:"ip"`
|
||||
Mac string `json:"mac"`
|
||||
Index int `json:"index"`
|
||||
Ifname string `json:"ifname"`
|
||||
NetId string `json:"net_id"`
|
||||
|
||||
Reference in New Issue
Block a user