Last active
November 20, 2015 06:34
-
-
Save iksaif/766edb53c78b2bb0bd97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/storage/remote/graphite/client.go b/storage/remote/graphite/client.go | |
index 7aa5a3e..f91de22 100644 | |
--- a/storage/remote/graphite/client.go | |
+++ b/storage/remote/graphite/client.go | |
@@ -47,7 +47,9 @@ func pathFromMetric(m model.Metric, prefix string) string { | |
var buffer bytes.Buffer | |
buffer.WriteString(prefix) | |
- buffer.WriteString(escape(m[model.MetricNameLabel])) | |
+ // Replace _ by . to spread metrics in Graphite. | |
+ buffer.WriteString( | |
+ strings.Replace(escape(m[model.MetricNameLabel]), "_", ".", -1)) | |
// We want to sort the labels. | |
labels := make(model.LabelNames, 0, len(m)) | |
diff --git a/storage/remote/graphite/client_test.go b/storage/remote/graphite/client_test.go | |
index cacf667..1766619 100644 | |
--- a/storage/remote/graphite/client_test.go | |
+++ b/storage/remote/graphite/client_test.go | |
@@ -47,7 +47,7 @@ func TestEscape(t *testing.T) { | |
func TestPathFromMetric(t *testing.T) { | |
expected := ("prefix." + | |
- "test:metric" + | |
+ "test.metric" + | |
".many_chars=abc!ABC:012-3!45%C3%B667~89%2E%2F\\(\\)\\{\\}\\,%3D%2E\\\"\\\\" + | |
".testlabel=test:value") | |
actual := pathFromMetric(metric, "prefix.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment