cc-metric-collector/receivers/metricReceiver.go

46 lines
929 B
Go
Raw Normal View History

2021-05-18 15:15:26 +02:00
package receivers
import (
// "time"
s "github.com/ClusterCockpit/cc-metric-collector/sinks"
influx "github.com/influxdata/line-protocol"
)
type ReceiverConfig struct {
2021-05-18 15:39:46 +02:00
Addr string `json:"address"`
2021-05-18 15:15:26 +02:00
Port string `json:"port"`
Database string `json:"database"`
Type string `json:"type"`
}
type Receiver struct {
2021-05-18 15:44:42 +02:00
name string
2021-05-18 15:15:26 +02:00
addr string
port string
database string
organization string
sink s.SinkFuncs
}
type ReceiverFuncs interface {
Init(config ReceiverConfig, sink s.SinkFuncs) error
Start()
Close()
}
func Tags2Map(metric influx.Metric) map[string]string {
tags := make(map[string]string)
for _, t := range metric.TagList() {
tags[t.Key] = t.Value
}
return tags
}
func Fields2Map(metric influx.Metric) map[string]interface{} {
fields := make(map[string]interface{})
for _, f := range metric.FieldList() {
fields[f.Key] = f.Value
}
return fields
}