mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-27 07:39:05 +01:00
Fix Write() arguments
This commit is contained in:
parent
aa842a8a9c
commit
2b07798af2
@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
"errors"
|
||||
lp "github.com/influxdata/line-protocol"
|
||||
)
|
||||
|
||||
type SqliteSink struct {
|
||||
@ -93,9 +94,26 @@ func (s *SqliteSink) PrepareLists(measurement string, tags map[string]string, fi
|
||||
return keytype, keys, values
|
||||
}
|
||||
|
||||
func (s *SqliteSink) Write(measurement string, tags map[string]string, fields map[string]interface{}, t time.Time) error {
|
||||
func Tags2Map(metric lp.MutableMetric) map[string]string {
|
||||
tags := make(map[string]string)
|
||||
for _, t := range metric.TagList() {
|
||||
tags[t.Key] = t.Value
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
||||
func Fields2Map(metric lp.MutableMetric) map[string]interface{} {
|
||||
fields := make(map[string]interface{})
|
||||
for _, f := range metric.FieldList() {
|
||||
fields[f.Key] = f.Value
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
func (s *SqliteSink) Write(point lp.MutableMetric) error {
|
||||
if s.db != nil {
|
||||
keytype, keys, values := s.PrepareLists(measurement, tags, fields, t)
|
||||
measurement := point.Name()
|
||||
keytype, keys, values := s.PrepareLists(measurement, Tags2Map(point), Fields2Map(point), point.Time())
|
||||
prim_key := []string{"time", "host"}
|
||||
if measurement == "cpu" {
|
||||
prim_key = append(prim_key, "cpu")
|
||||
|
Loading…
Reference in New Issue
Block a user