mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-29 07:29:42 -08:00
Merge pull request #1302 from iksaif/master
Use '.' instead of '=' to separate labels from their values in Graphite
This commit is contained in:
commit
e0efe75c2d
|
@ -63,11 +63,11 @@ func pathFromMetric(m model.Metric, prefix string) string {
|
||||||
if l == model.MetricNameLabel || len(l) == 0 {
|
if l == model.MetricNameLabel || len(l) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Here we use '=' instead of '.' to be able
|
// Since we use '.' instead of '=' to separate label and values
|
||||||
// to later read back the value correctly. Using '.' would
|
// it means that we can't have an '.' in the metric name. Fortunately
|
||||||
// not allow to distinguish labels from values.
|
// this is prohibited in prometheus metrics.
|
||||||
buffer.WriteString(fmt.Sprintf(
|
buffer.WriteString(fmt.Sprintf(
|
||||||
".%s=%s", string(l), escape(v)))
|
".%s.%s", string(l), escape(v)))
|
||||||
}
|
}
|
||||||
return buffer.String()
|
return buffer.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ func TestEscape(t *testing.T) {
|
||||||
func TestPathFromMetric(t *testing.T) {
|
func TestPathFromMetric(t *testing.T) {
|
||||||
expected := ("prefix." +
|
expected := ("prefix." +
|
||||||
"test:metric" +
|
"test:metric" +
|
||||||
".many_chars=abc!ABC:012-3!45%C3%B667~89%2E%2F\\(\\)\\{\\}\\,%3D%2E\\\"\\\\" +
|
".many_chars.abc!ABC:012-3!45%C3%B667~89%2E%2F\\(\\)\\{\\}\\,%3D%2E\\\"\\\\" +
|
||||||
".testlabel=test:value")
|
".testlabel.test:value")
|
||||||
actual := pathFromMetric(metric, "prefix.")
|
actual := pathFromMetric(metric, "prefix.")
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
t.Errorf("Expected %s, got %s", expected, actual)
|
t.Errorf("Expected %s, got %s", expected, actual)
|
||||||
|
|
Loading…
Reference in a new issue