Change storage format

This commit is contained in:
Thomas Roehl
2021-10-04 15:23:43 +02:00
parent 8956ce7ad5
commit 558bbaba59
19 changed files with 874 additions and 283 deletions

View File

@@ -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
}