Skip to content
Snippets Groups Projects
Commit d09bb13c authored by david birdsong's avatar david birdsong Committed by Cameron Sparr
Browse files

special case 'value'

it usually connotes a single value type metric, appending just clutters

closes #793
parent 31c323c0
No related branches found
No related tags found
No related merge requests found
...@@ -79,7 +79,12 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error { ...@@ -79,7 +79,12 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
} }
for n, val := range point.Fields() { 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 { if _, ok := p.metrics[mname]; !ok {
p.metrics[mname] = prometheus.NewUntypedVec( p.metrics[mname] = prometheus.NewUntypedVec(
prometheus.UntypedOpts{ prometheus.UntypedOpts{
......
...@@ -46,8 +46,8 @@ func TestPrometheusWritePointEmptyTag(t *testing.T) { ...@@ -46,8 +46,8 @@ func TestPrometheusWritePointEmptyTag(t *testing.T) {
value float64 value float64
tags map[string]string tags map[string]string
}{ }{
{"test_point_1_value", 0.0, tags}, {"test_point_1", 0.0, tags},
{"test_point_2_value", 1.0, tags}, {"test_point_2", 1.0, tags},
} }
var acc testutil.Accumulator var acc testutil.Accumulator
...@@ -78,8 +78,8 @@ func TestPrometheusWritePointEmptyTag(t *testing.T) { ...@@ -78,8 +78,8 @@ func TestPrometheusWritePointEmptyTag(t *testing.T) {
name string name string
value float64 value float64
}{ }{
{"test_point_3_value", 0.0}, {"test_point_3", 0.0},
{"test_point_4_value", 1.0}, {"test_point_4", 1.0},
} }
require.NoError(t, p.Gather(&acc)) require.NoError(t, p.Gather(&acc))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment