mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-08 22:45:55 +02:00
Add meta as tag logic to sampleSink
This commit is contained in:
parent
4800b33ceb
commit
dce6bf851f
@ -10,14 +10,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SampleSinkConfig struct {
|
type SampleSinkConfig struct {
|
||||||
// defines JSON tags for 'type' and 'meta_as_tags'
|
// defines JSON tags for 'type' and 'meta_as_tags' (string list)
|
||||||
// See: metricSink.go
|
// See: metricSink.go
|
||||||
defaultSinkConfig
|
defaultSinkConfig
|
||||||
// Additional config options, for SampleSink
|
// Additional config options, for SampleSink
|
||||||
}
|
}
|
||||||
|
|
||||||
type SampleSink struct {
|
type SampleSink struct {
|
||||||
// declares elements 'name' and 'meta_as_tags'
|
// declares elements 'name' and 'meta_as_tags' (string to bool map!)
|
||||||
sink
|
sink
|
||||||
config SampleSinkConfig // entry point to the SampleSinkConfig
|
config SampleSinkConfig // entry point to the SampleSinkConfig
|
||||||
}
|
}
|
||||||
@ -28,6 +28,7 @@ type SampleSink struct {
|
|||||||
|
|
||||||
// Code to submit a single CCMetric to the sink
|
// Code to submit a single CCMetric to the sink
|
||||||
func (s *SampleSink) Write(point lp.CCMetric) error {
|
func (s *SampleSink) Write(point lp.CCMetric) error {
|
||||||
|
// based on s.meta_as_tags use meta infos as tags
|
||||||
log.Print(point)
|
log.Print(point)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -62,6 +63,12 @@ func NewSampleSink(name string, config json.RawMessage) (Sink, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
// Check if all required fields in the config are set
|
// Check if all required fields in the config are set
|
||||||
// E.g. use 'len(s.config.Option) > 0' for string settings
|
// E.g. use 'len(s.config.Option) > 0' for string settings
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user