mirror of https://github.com/prometheus/prometheus
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>pull/15341/head
parent
1b2defa7a2
commit
d19e749dc6
|
@ -157,6 +157,20 @@ describe("serializeNode and formatNode", () => {
|
|||
},
|
||||
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.
|
||||
{
|
||||
|
|
|
@ -271,7 +271,7 @@ const metricNameRe = /^[a-zA-Z_:][a-zA-Z0-9_:]*$/;
|
|||
const labelNameCharsetRe = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
||||
|
||||
export const metricContainsExtendedCharset = (str: string) => {
|
||||
return !metricNameRe.test(str);
|
||||
return str !== "" && !metricNameRe.test(str);
|
||||
};
|
||||
|
||||
export const labelNameContainsExtendedCharset = (str: string) => {
|
||||
|
|
Loading…
Reference in New Issue