mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Fix selector / series formatting for empty metric names
Fixes https://github.com/prometheus/prometheus/issues/15335 Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
02aa6d1de6
commit
c1f8036228
|
@ -157,6 +157,20 @@ describe("serializeNode and formatNode", () => {
|
||||||
},
|
},
|
||||||
output: "metric_name[5m] @ start() offset -10m",
|
output: "metric_name[5m] @ start() offset -10m",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
type: nodeType.vectorSelector,
|
||||||
|
name: "", // Test formatting a selector with an empty metric name.
|
||||||
|
matchers: [
|
||||||
|
{ type: matchType.equal, name: "label1", value: "value1" },
|
||||||
|
],
|
||||||
|
offset: 0,
|
||||||
|
timestamp: null,
|
||||||
|
startOrEnd: null,
|
||||||
|
},
|
||||||
|
output:
|
||||||
|
'{label1="value1"}',
|
||||||
|
},
|
||||||
|
|
||||||
// Aggregations.
|
// Aggregations.
|
||||||
{
|
{
|
||||||
|
|
|
@ -271,7 +271,7 @@ const metricNameRe = /^[a-zA-Z_:][a-zA-Z0-9_:]*$/;
|
||||||
const labelNameCharsetRe = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
const labelNameCharsetRe = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
||||||
|
|
||||||
export const metricContainsExtendedCharset = (str: string) => {
|
export const metricContainsExtendedCharset = (str: string) => {
|
||||||
return !metricNameRe.test(str);
|
return str !== "" && !metricNameRe.test(str);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const labelNameContainsExtendedCharset = (str: string) => {
|
export const labelNameContainsExtendedCharset = (str: string) => {
|
||||||
|
|
Loading…
Reference in a new issue