Skip to content

Commit

Permalink
special case 'value'
Browse files Browse the repository at this point in the history
it usually connotes a single value type metric, appending just clutters

closes #793
  • Loading branch information
david birdsong authored and sparrc committed Mar 21, 2016
1 parent 31c323c commit d09bb13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion plugins/outputs/prometheus_client/prometheus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
}

for n, val := range point.Fields() {
mname := fmt.Sprintf("%s_%s", key, n)
var mname string
if n == "value" {
mname = key
} else {
mname = fmt.Sprintf("%s_%s", key, n)
}
if _, ok := p.metrics[mname]; !ok {
p.metrics[mname] = prometheus.NewUntypedVec(
prometheus.UntypedOpts{
Expand Down
8 changes: 4 additions & 4 deletions plugins/outputs/prometheus_client/prometheus_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func TestPrometheusWritePointEmptyTag(t *testing.T) {
value float64
tags map[string]string
}{
{"test_point_1_value", 0.0, tags},
{"test_point_2_value", 1.0, tags},
{"test_point_1", 0.0, tags},
{"test_point_2", 1.0, tags},
}

var acc testutil.Accumulator
Expand Down Expand Up @@ -78,8 +78,8 @@ func TestPrometheusWritePointEmptyTag(t *testing.T) {
name string
value float64
}{
{"test_point_3_value", 0.0},
{"test_point_4_value", 1.0},
{"test_point_3", 0.0},
{"test_point_4", 1.0},
}

require.NoError(t, p.Gather(&acc))
Expand Down

0 comments on commit d09bb13

Please sign in to comment.