mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
5a5122e7e3
commit
26626d9073
@ -140,8 +140,7 @@ func formatLegend(metric model.Metric, query *PrometheusQuery) string {
|
|||||||
if val, exists := metric[model.LabelName(labelName)]; exists {
|
if val, exists := metric[model.LabelName(labelName)]; exists {
|
||||||
return []byte(val)
|
return []byte(val)
|
||||||
}
|
}
|
||||||
|
return []byte{}
|
||||||
return in
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return string(result)
|
return string(result)
|
||||||
|
@ -28,7 +28,7 @@ func TestPrometheus(t *testing.T) {
|
|||||||
LegendFormat: "legend {{app}} {{ device }} {{broken}}",
|
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() {
|
Convey("build full serie name", func() {
|
||||||
|
@ -166,7 +166,7 @@ export class ResultTransformer {
|
|||||||
if (aliasData[g1]) {
|
if (aliasData[g1]) {
|
||||||
return aliasData[g1];
|
return aliasData[g1];
|
||||||
}
|
}
|
||||||
return g1;
|
return '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user