mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 14:39:40 -08:00
Merge pull request #15340 from prometheus/fix/empty-metric-name-formatting
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (0) (push) Waiting to run
CI / Build Prometheus for common architectures (1) (push) Waiting to run
CI / Build Prometheus for common architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (0) (push) Waiting to run
CI / Build Prometheus for all architectures (1) (push) Waiting to run
CI / Build Prometheus for all architectures (10) (push) Waiting to run
CI / Build Prometheus for all architectures (11) (push) Waiting to run
CI / Build Prometheus for all architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (3) (push) Waiting to run
CI / Build Prometheus for all architectures (4) (push) Waiting to run
CI / Build Prometheus for all architectures (5) (push) Waiting to run
CI / Build Prometheus for all architectures (6) (push) Waiting to run
CI / Build Prometheus for all architectures (7) (push) Waiting to run
CI / Build Prometheus for all architectures (8) (push) Waiting to run
CI / Build Prometheus for all architectures (9) (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (0) (push) Waiting to run
CI / Build Prometheus for common architectures (1) (push) Waiting to run
CI / Build Prometheus for common architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (0) (push) Waiting to run
CI / Build Prometheus for all architectures (1) (push) Waiting to run
CI / Build Prometheus for all architectures (10) (push) Waiting to run
CI / Build Prometheus for all architectures (11) (push) Waiting to run
CI / Build Prometheus for all architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (3) (push) Waiting to run
CI / Build Prometheus for all architectures (4) (push) Waiting to run
CI / Build Prometheus for all architectures (5) (push) Waiting to run
CI / Build Prometheus for all architectures (6) (push) Waiting to run
CI / Build Prometheus for all architectures (7) (push) Waiting to run
CI / Build Prometheus for all architectures (8) (push) Waiting to run
CI / Build Prometheus for all architectures (9) (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Fix selector / series formatting for empty metric names
This commit is contained in:
commit
3c5551df68
|
@ -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