Fix snmp overriding of auto-configured table fields (#4208)
Whenever the snmp plugin was configured with a table with automatic field discovery, if one of those fields was explicitly overridden in the config and the value of is_tag was changed, the field would be duplicated, once as a tag & once as a field. This change fixes the behavior so that if a field is explicitly configured, automatic table field discovery doesn't touch it.
This commit is contained in:
committed by
Daniel Nelson
parent
bd95f42e14
commit
0fd9c1b0ce
@@ -218,10 +218,20 @@ func (t *Table) initBuild() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if t.Name == "" {
|
||||
t.Name = oidText
|
||||
}
|
||||
t.Fields = append(t.Fields, fields...)
|
||||
|
||||
knownOIDs := map[string]bool{}
|
||||
for _, f := range t.Fields {
|
||||
knownOIDs[f.Oid] = true
|
||||
}
|
||||
for _, f := range fields {
|
||||
if !knownOIDs[f.Oid] {
|
||||
t.Fields = append(t.Fields, f)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user