mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-09-16 13:24:32 +02:00
Meta to tags list and map for sinks (#63)
* Change ccMetric->Influx functions * Use a meta_as_tags string list in config but create a lookup map afterwards * Add meta as tag logic to sampleSink
This commit is contained in:
@@ -89,7 +89,7 @@ func (s *InfluxAsyncSink) connect() error {
|
||||
|
||||
func (s *InfluxAsyncSink) Write(m lp.CCMetric) error {
|
||||
s.writeApi.WritePoint(
|
||||
m.ToPoint(s.config.MetaAsTags),
|
||||
m.ToPoint(s.meta_as_tags),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
@@ -152,6 +152,11 @@ func NewInfluxAsyncSink(name string, config json.RawMessage) (Sink, error) {
|
||||
len(s.config.Password) == 0 {
|
||||
return nil, errors.New("not all configuration variables set required by InfluxAsyncSink")
|
||||
}
|
||||
// Create lookup map to use meta infos as tags in the output metric
|
||||
s.meta_as_tags = make(map[string]bool)
|
||||
for _, k := range s.config.MetaAsTags {
|
||||
s.meta_as_tags[k] = true
|
||||
}
|
||||
|
||||
toUint := func(duration string, def uint) uint {
|
||||
t, err := time.ParseDuration(duration)
|
||||
|
Reference in New Issue
Block a user