Commit 26626d90 by Denis Committed by GitHub

Prometheus: Render missing labels in legend formats as an empty string (#22355)

* Empty value for unknown Prometheus label (grafana#16041)

* Empty value for unknown Prometheus label (grafana#16041)

* fix linter
parent 5a5122e7
......@@ -140,8 +140,7 @@ func formatLegend(metric model.Metric, query *PrometheusQuery) string {
if val, exists := metric[model.LabelName(labelName)]; exists {
return []byte(val)
}
return in
return []byte{}
})
return string(result)
......
......@@ -28,7 +28,7 @@ func TestPrometheus(t *testing.T) {
LegendFormat: "legend {{app}} {{ device }} {{broken}}",
}
So(formatLegend(metric, query), ShouldEqual, "legend backend mobile {{broken}}")
So(formatLegend(metric, query), ShouldEqual, "legend backend mobile ")
})
Convey("build full serie name", func() {
......
......@@ -166,7 +166,7 @@ export class ResultTransformer {
if (aliasData[g1]) {
return aliasData[g1];
}
return g1;
return '';
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment