Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,11 @@ func indexesToLabels(indexOids []int, metric *config.Metric, oidToPdu map[string
}
oid := lookup.Oid
for _, label := range lookup.Labels {
oid = fmt.Sprintf("%s.%s", oid, listToOid(labelOids[label]))
if _, err := strconv.ParseUint(label, 10, 64); err == nil {
oid = fmt.Sprintf("%s.%v", oid, label)
} else {
oid = fmt.Sprintf("%s.%s", oid, listToOid(labelOids[label]))
}
}
if pdu, ok := oidToPdu[oid]; ok {
t := lookup.Type
Expand Down
1 change: 1 addition & 0 deletions generator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ type Lookup struct {
SourceIndexes []string `yaml:"source_indexes"`
Lookup string `yaml:"lookup"`
DropSourceIndexes bool `yaml:"drop_source_indexes,omitempty"`
CustomLabelName string `yaml:"custom_label_name,omitempty"`
}
10 changes: 10 additions & 0 deletions generator/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,13 @@
}
}
}
if foundIndexes != len(lookup.SourceIndexes) {
for _, index := range lookup.SourceIndexes {
if _, err := strconv.ParseUint(index, 10, 64); err == nil {
foundIndexes++
}
}
}
if foundIndexes == len(lookup.SourceIndexes) {
if _, ok := nameToNode[lookup.Lookup]; !ok {
return nil, fmt.Errorf("unknown index '%s'", lookup.Lookup)
Expand All @@ -460,6 +467,9 @@
Type: typ,
Oid: indexNode.Oid,
}
if len(lookup.CustomLabelName) > 0 {

Check failure on line 470 in generator/tree.go

View workflow job for this annotation

GitHub Actions / lint

emptyStringTest: replace `len(lookup.CustomLabelName) > 0` with `lookup.CustomLabelName != ""` (gocritic)
l.Labelname = sanitizeLabelName(lookup.CustomLabelName)
}
for _, oldIndex := range lookup.SourceIndexes {
l.Labels = append(l.Labels, sanitizeLabelName(oldIndex))
}
Expand Down
Loading