Add two helper functions to collector definition

This commit is contained in:
Thomas Roehl 2021-10-08 13:28:02 +02:00
parent 7f1694adc7
commit 4688997071

View File

@ -116,3 +116,19 @@ func CpuList() []int {
} }
return cpulist return cpulist
} }
func Tags2Map(metric lp.Metric) map[string]string {
tags := make(map[string]string)
for _, t := range metric.TagList() {
tags[t.Key] = t.Value
}
return tags
}
func Fields2Map(metric lp.Metric) map[string]interface{} {
fields := make(map[string]interface{})
for _, f := range metric.FieldList() {
fields[f.Key] = f.Value
}
return fields
}