mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-26 15:29:04 +01:00
Fix format of StdoutSink
This commit is contained in:
parent
913c3719a9
commit
fe87b2c7cb
@ -1,10 +1,10 @@
|
|||||||
package sinks
|
package sinks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
"math"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StdoutSink struct {
|
type StdoutSink struct {
|
||||||
@ -21,24 +21,24 @@ func (s *StdoutSink) Init(host string, port string, user string, password string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *StdoutSink) Write(measurement string, tags map[string]string, fields map[string]interface{}, t time.Time) error {
|
func (s *StdoutSink) Write(measurement string, tags map[string]string, fields map[string]interface{}, t time.Time) error {
|
||||||
var tagsstr []string
|
var tagsstr []string
|
||||||
var fieldstr []string
|
var fieldstr []string
|
||||||
for k,v := range tags {
|
for k, v := range tags {
|
||||||
tagsstr = append(tagsstr, fmt.Sprintf("%s=%s", k, v))
|
tagsstr = append(tagsstr, fmt.Sprintf("%s=%s", k, v))
|
||||||
}
|
}
|
||||||
for k,v := range fields {
|
for k, v := range fields {
|
||||||
if !math.IsNaN(v.(float64)) {
|
if !math.IsNaN(v.(float64)) {
|
||||||
fieldstr = append(fieldstr, fmt.Sprintf("%s=%v", k, v.(float64)))
|
fieldstr = append(fieldstr, fmt.Sprintf("%s=%v", k, v.(float64)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(tagsstr) > 0 {
|
if len(tagsstr) > 0 {
|
||||||
fmt.Printf("%s,%s %s %d\n", measurement, strings.Join(tagsstr, ","), strings.Join(fieldstr, ","), t.Unix())
|
fmt.Printf("%s,%s %s %d\n", measurement, strings.Join(tagsstr, ","), strings.Join(fieldstr, ","), t.Unix())
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s %s %d\n", measurement, strings.Join(fieldstr, ","), t.Unix())
|
fmt.Printf("%s %s %d\n", measurement, strings.Join(fieldstr, ","), t.Unix())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StdoutSink) Close() {
|
func (s *StdoutSink) Close() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user