From 3541b947f190a14ca1356ececa027c696597014b Mon Sep 17 00:00:00 2001 From: Flavien David Date: Mon, 14 Oct 2024 08:43:23 +0200 Subject: [PATCH] Improve Prometheus regexp (#8039) --- alerting/temporal/src/qdrant/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/alerting/temporal/src/qdrant/index.ts b/alerting/temporal/src/qdrant/index.ts index 5a9349375aad..840599c940e3 100644 --- a/alerting/temporal/src/qdrant/index.ts +++ b/alerting/temporal/src/qdrant/index.ts @@ -53,8 +53,15 @@ const NODE_AND_CLUSTER_REGEXP = /https:\/\/(node-\d+)-(.+)\:\d+/; */ // Example: "grpc_responses_max_duration_seconds{endpoint="/qdrant.Points/Search"} 3.701747". -const prometheusMetricsRegexp = /(\w+)(?:\{([^}]*)\})? (\d+(\.\d+)?)/; -const supportedPrometheusLabels = ["endpoint", "le"] as const; +// Support nested curly braces in labels. +const prometheusMetricsRegexp = + /(\w+)(?:\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\})? (\d+(?:\.\d+)?)/; +const supportedPrometheusLabels = [ + "endpoint", + "le", + "method", + "status", +] as const; type SupportedPrometheusLabels = (typeof supportedPrometheusLabels)[number]; function isSupportedPrometheusLabel( @@ -82,6 +89,7 @@ function extractMetricDetails(line: string) { return { name, labels, value }; } + return null; }