Skip to content

Commit

Permalink
Update compatibility with influxdb model
Browse files Browse the repository at this point in the history
Updates to interface with influxdb model.

See: influxdata/influxdb#7138
  • Loading branch information
SuperQ committed Jul 27, 2017
1 parent 1e9cb7e commit 4fbf520
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ func (c *influxDBCollector) influxDBPost(w http.ResponseWriter, r *http.Request)

func (c *influxDBCollector) parsePointsToSample(points []models.Point) {
for _, s := range points {
for field, v := range s.Fields() {
fields, err := s.Fields()
if err != nil {
log.Errorf("error getting fields from point: %s", err)
continue
}
for field, v := range fields {
var value float64
switch v := v.(type) {
case float64:
Expand All @@ -157,7 +162,7 @@ func (c *influxDBCollector) parsePointsToSample(points []models.Point) {

var name string
if field == "value" {
name = s.Name()
name = string(s.Name())
} else {
name = fmt.Sprintf("%s_%s", s.Name(), field)
}
Expand All @@ -168,8 +173,8 @@ func (c *influxDBCollector) parsePointsToSample(points []models.Point) {
Value: value,
Labels: map[string]string{},
}
for k, v := range s.Tags() {
sample.Labels[invalidChars.ReplaceAllString(k, "_")] = v
for _, v := range s.Tags() {
sample.Labels[invalidChars.ReplaceAllString(string(v.Key), "_")] = string(v.Value)
}

// Calculate a consistent unique ID for the sample.
Expand Down

0 comments on commit 4fbf520

Please sign in to comment.