mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-08 22:45:55 +02:00
Add metric renaming function
This commit is contained in:
parent
412b708bce
commit
7d0b1c268f
@ -69,6 +69,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
@ -95,6 +96,23 @@ type LibgangliaSink struct {
|
|||||||
cstrCache map[string]*C.char
|
cstrCache map[string]*C.char
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gangliaMetricName(point lp.CCMetric) string {
|
||||||
|
name := point.Name()
|
||||||
|
metricType, typeOK := point.GetTag("type")
|
||||||
|
metricTid, tidOk := point.GetTag("type-id")
|
||||||
|
gangliaType := metricType + metricTid
|
||||||
|
if strings.Contains(name, metricType) && tidOk {
|
||||||
|
name = strings.Replace(name, metricType, gangliaType, -1)
|
||||||
|
} else if typeOK && tidOk {
|
||||||
|
name = metricType + metricTid + "_" + name
|
||||||
|
} else if point.HasTag("device") {
|
||||||
|
device, _ := point.GetTag("device")
|
||||||
|
name = name + "_" + device
|
||||||
|
}
|
||||||
|
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
func (s *LibgangliaSink) Init(config json.RawMessage) error {
|
func (s *LibgangliaSink) Init(config json.RawMessage) error {
|
||||||
var err error = nil
|
var err error = nil
|
||||||
s.name = "LibgangliaSink"
|
s.name = "LibgangliaSink"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user