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
This commit is contained in:
Denis 2020-03-18 21:57:11 +03:00 committed by GitHub
parent 5a5122e7e3
commit 26626d9073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 4 deletions

View File

@ -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)

View File

@ -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() {

View File

@ -166,7 +166,7 @@ export class ResultTransformer {
if (aliasData[g1]) {
return aliasData[g1];
}
return g1;
return '';
});
}