in translator/setMetricPath.go [22:89]
func SetMetricPath(result map[string]interface{}, sectionKey string) {
if i, ok := result[inputPluginKey]; ok {
inputs := i.(map[string]interface{})
for _, v := range inputs {
inputArray := v.([]interface{})
for _, inputIntf := range inputArray {
input := inputIntf.(map[string]interface{})
if val, ok := input[tagKey]; ok {
tags := val.(map[string]interface{})
// If a plugin already has its own metricPath value, we do not want to override its value.
if _, ok := tags[routingTagKey]; !ok {
tags[routingTagKey] = sectionKey
}
} else {
input[tagKey] = map[string]interface{}{routingTagKey: sectionKey}
}
}
}
}
if p, ok := result[processorPluginKey]; ok {
processors := p.(map[string]interface{})
for _, v := range processors {
processorArray := v.([]interface{})
for _, processorIntf := range processorArray {
processor := processorIntf.(map[string]interface{})
if val, ok := processor[tagPassKey]; ok {
tagPass := val.(map[string][]string)
if tags, ok := tagPass[routingTagKey]; ok {
tagPass[routingTagKey] = append(tags, sectionKey)
} else {
tagPass[routingTagKey] = []string{sectionKey}
}
} else {
processor[tagPassKey] = map[string][]string{routingTagKey: {sectionKey}}
}
}
}
}
if o, ok := result[outputPluginKey]; ok {
outputs := o.(map[string]interface{})
for _, v := range outputs {
outputArray := v.([]interface{})
for _, outputIntf := range outputArray {
output := outputIntf.(map[string]interface{})
if val, ok := output[tagPassKey]; ok {
tagPass := val.(map[string][]string)
if tags, ok := tagPass[routingTagKey]; ok {
tagPass[routingTagKey] = append(tags, sectionKey)
} else {
tagPass[routingTagKey] = []string{sectionKey}
}
} else {
output[tagPassKey] = map[string][]string{routingTagKey: {sectionKey}}
}
if val, ok := output[tagExcludeKey]; ok {
tagExclude := val.([]string)
if !contains(tagExclude, routingTagKey) {
output[tagExcludeKey] = append(tagExclude, routingTagKey)
}
} else {
output[tagExcludeKey] = []string{routingTagKey}
}
}
}
}
}