mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-07-19 03:11:41 +02:00
Change storage format
This commit is contained in:
@@ -6,8 +6,8 @@ import (
|
||||
"fmt"
|
||||
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||
influxdb2Api "github.com/influxdata/influxdb-client-go/v2/api"
|
||||
lp "github.com/influxdata/line-protocol"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
type InfluxSink struct {
|
||||
@@ -48,8 +48,16 @@ func (s *InfluxSink) Init(config SinkConfig) error {
|
||||
return s.connect()
|
||||
}
|
||||
|
||||
func (s *InfluxSink) Write(measurement string, tags map[string]string, fields map[string]interface{}, t time.Time) error {
|
||||
p := influxdb2.NewPoint(measurement, tags, fields, t)
|
||||
func (s *InfluxSink) Write(point lp.MutableMetric) error {
|
||||
var tags map[string]string
|
||||
var fields map[string]interface{}
|
||||
for _, t := range point.TagList() {
|
||||
tags[t.Key] = t.Value
|
||||
}
|
||||
for _, f := range point.FieldList() {
|
||||
fields[f.Key] = f.Value
|
||||
}
|
||||
p := influxdb2.NewPoint(point.Name(), tags, fields, point.Time())
|
||||
err := s.writeApi.WritePoint(context.Background(), p)
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user