Skip to content

Commit

Permalink
Collectd input should use "value" as field name
Browse files Browse the repository at this point in the history
Fixes issue #2412
  • Loading branch information
otoolep committed Apr 30, 2015
1 parent c3e6ea2 commit e5dd2ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion collectd/collectd.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func Unmarshal(data *gollectd.Packet) []influxdb.Point {
tags := make(map[string]string)
fields := make(map[string]interface{})

fields[name] = data.Values[i].Value
fields["value"] = data.Values[i].Value

if data.Hostname != "" {
tags["host"] = data.Hostname
Expand Down
10 changes: 5 additions & 5 deletions collectd/collectd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func TestUnmarshal_Points(t *testing.T) {
},
},
points: []influxdb.Point{
{Name: "disk_read", Fields: map[string]interface{}{"disk_read": float64(1)}},
{Name: "disk_read", Fields: map[string]interface{}{"value": float64(1)}},
},
},
{
Expand All @@ -230,8 +230,8 @@ func TestUnmarshal_Points(t *testing.T) {
},
},
points: []influxdb.Point{
{Name: "disk_read", Fields: map[string]interface{}{"disk_read": float64(1)}},
{Name: "disk_write", Fields: map[string]interface{}{"disk_write": float64(5)}},
{Name: "disk_read", Fields: map[string]interface{}{"value": float64(1)}},
{Name: "disk_write", Fields: map[string]interface{}{"value": float64(5)}},
},
},
{
Expand All @@ -250,7 +250,7 @@ func TestUnmarshal_Points(t *testing.T) {
{
Name: "disk_read",
Tags: map[string]string{"host": "server01", "instance": "sdk", "type": "disk_octets", "type_instance": "single"},
Fields: map[string]interface{}{"disk_read": float64(1)},
Fields: map[string]interface{}{"value": float64(1)},
},
},
},
Expand All @@ -269,7 +269,7 @@ func TestUnmarshal_Points(t *testing.T) {
t.Errorf("point name mismatch. expected %q, got %q", name, m.Name)
}
// test value
mv := m.Fields[m.Name].(float64)
mv := m.Fields["value"].(float64)
pv := test.packet.Values[i].Value
if mv != pv {
t.Errorf("point value mismatch. expected %v, got %v", pv, mv)
Expand Down

0 comments on commit e5dd2ba

Please sign in to comment.