0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-09 15:47:53 +00:00

go.d prometheus fix units for snmp_exporter ()

This commit is contained in:
Ilya Mashchenko 2024-04-25 14:34:53 +03:00 committed by GitHub
parent 63ec0d89dd
commit f91e91bb71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -280,6 +280,21 @@ func getChartUnits(metric string) string {
idx := strings.LastIndexByte(metric, '_')
if idx == -1 {
// snmp_exporter: e.g. ifOutUcastPkts, ifOutOctets.
if idx = strings.LastIndexFunc(metric, func(r rune) bool { return r >= 'A' && r <= 'Z' }); idx != -1 {
v := strings.ToLower(metric[idx:])
switch v {
case "pkts":
return "packets"
case "octets":
return "bytes"
case "mtu":
return "octets"
case "speed":
return "bits"
}
return v
}
return "events"
}
switch suffix := metric[idx:]; suffix {