mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-26 15:29:04 +01:00
Use FromInfluxMetric() to convert influx to cc metric
This commit is contained in:
parent
e1a7379c2e
commit
4e0782d66b
@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
ccmetric "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
influx "github.com/influxdata/line-protocol"
|
influx "github.com/influxdata/line-protocol"
|
||||||
)
|
)
|
||||||
@ -97,7 +98,8 @@ func (m *CustomCmdCollector) Read(interval time.Duration, output chan lp.CCMetri
|
|||||||
if skip {
|
if skip {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
y, err := lp.New(c.Name(), Tags2Map(c), m.meta, Fields2Map(c), c.Time())
|
|
||||||
|
y := ccmetric.FromInfluxMetric(c)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
output <- y
|
output <- y
|
||||||
}
|
}
|
||||||
@ -119,7 +121,7 @@ func (m *CustomCmdCollector) Read(interval time.Duration, output chan lp.CCMetri
|
|||||||
if skip {
|
if skip {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
y, err := lp.New(f.Name(), Tags2Map(f), m.meta, Fields2Map(f), f.Time())
|
y := ccmetric.FromInfluxMetric(f)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
output <- y
|
output <- y
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
influx "github.com/influxdata/line-protocol"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MetricCollector interface {
|
type MetricCollector interface {
|
||||||
@ -115,24 +114,6 @@ func CpuList() []int {
|
|||||||
return cpulist
|
return cpulist
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tags2Map stores a InfluxDB list of tags in a map of key value pairs
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fields2Map stores a InfluxDB list of fields in a map of key value pairs
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveFromStringList removes the string r from the array of strings s
|
// RemoveFromStringList removes the string r from the array of strings s
|
||||||
// If r is not contained in the array an error is returned
|
// If r is not contained in the array an error is returned
|
||||||
func RemoveFromStringList(s []string, r string) ([]string, error) {
|
func RemoveFromStringList(s []string, r string) ([]string, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user