fix(go.d/ddsnmp): remove singular-to-plural conversion in metric family (#20517)
* fix(go.d/ddsnmp): remove singular-to-plural conversion in metric family processing * fix uptime unit
Ilya Mashchenko committed
Jun 18, 2025 at 18:28 UTC
b95cda041da9c24d2454b66d1484d70806161fe0
2 files changed
+6
-3
src/go/plugin/go.d/collector/snmp/ddsnmp/ddsnmpcollector/collector.go
+5
-2
@@ -219,7 +219,7 @@ func (c *Collector) snmpGet(oids []string) (map[string]gosnmp.SnmpPDU, error) {
219
}
220
221
func processMetricFamily(family, devType, vendor string) string {
222
- prefix := strings.TrimPrefix(devType+"s/"+vendor, "s/")
222
+ prefix := strings.TrimPrefix(devType+"/"+vendor, "/")
223
if prefix == "" {
224
return family
225
}
@@ -229,7 +229,10 @@ func processMetricFamily(family, devType, vendor string) string {
229
230
parts := strings.Split(family, "/")
231
parts = slices.DeleteFunc(parts, func(s string) bool {
232
- return strings.EqualFold(s, devType) || strings.EqualFold(s, devType+"s") || strings.EqualFold(s, vendor)
232
+ return strings.EqualFold(s, devType) ||
233
+ strings.EqualFold(s, devType+"s") ||
234
+ strings.EqualFold(s, devType+"es") ||
235
+ strings.EqualFold(s, vendor)
236
})
237
238
return strings.TrimSuffix(prefix+"/"+strings.Join(parts, "/"), "/")
src/go/plugin/go.d/config/go.d/snmp.profiles/default/_base.yaml
+1
-1
@@ -16,7 +16,7 @@ metrics:
16
description: Time since the system was last rebooted or powered on.
17
scale_factor: 0.01
18
family: Uptime
19
- unit: seconds
19
+ unit: s
20
21
metadata:
22
device: