mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-10-31 00:55:06 +01:00 
			
		
		
		
	Add metric renaming function
This commit is contained in:
		| @@ -69,6 +69,7 @@ import ( | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric" | ||||
| @@ -95,6 +96,23 @@ type LibgangliaSink struct { | ||||
| 	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 { | ||||
| 	var err error = nil | ||||
| 	s.name = "LibgangliaSink" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user