Skip to content

Commit

Permalink
Allow colons in metric names in prometheus_client output (influxdata#…
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjsullivan authored and Helge Waastad committed Jun 13, 2019
1 parent b9b1124 commit 323a01b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/outputs/prometheus_client/prometheus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

var (
invalidNameCharRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
invalidNameCharRE = regexp.MustCompile(`[^a-zA-Z0-9_:]`)
validNameCharRE = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_]*`)
)

Expand Down
6 changes: 3 additions & 3 deletions plugins/outputs/prometheus_client/prometheus_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ func TestWrite_Sanitize(t *testing.T) {
client := NewClient()

p1, err := metric.New(
"foo.bar",
"foo.bar:colon",
map[string]string{"tag-with-dash": "localhost.local"},
map[string]interface{}{"field-with-dash": 42},
map[string]interface{}{"field-with-dash-and:colon": 42},
time.Now(),
telegraf.Counter)
err = client.Write([]telegraf.Metric{p1})
require.NoError(t, err)

fam, ok := client.fam["foo_bar_field_with_dash"]
fam, ok := client.fam["foo_bar:colon_field_with_dash_and:colon"]
require.True(t, ok)
require.Equal(t, map[string]int{"tag_with_dash": 1}, fam.LabelSet)

Expand Down

0 comments on commit 323a01b

Please sign in to comment.