summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2024-04-25 14:34:53 +0300
committerGitHub <noreply@github.com>2024-04-25 14:34:53 +0300
commitf91e91bb71ff05abd54cb3e90d95e2370f9e165e (patch)
tree157f666c3ff34ab8645bd8acdefbba4ead6660d3
parent63ec0d89dd6ac9ec739aa3af346882a1a6a945f3 (diff)
go.d prometheus fix units for snmp_exporter (#17524)
-rw-r--r--src/go/collectors/go.d.plugin/modules/prometheus/charts.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/prometheus/charts.go b/src/go/collectors/go.d.plugin/modules/prometheus/charts.go
index 61e8031d75..72d93020e2 100644
--- a/src/go/collectors/go.d.plugin/modules/prometheus/charts.go
+++ b/src/go/collectors/go.d.plugin/modules/prometheus/charts.go
@@ -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 {