Skip to content

Commit

Permalink
Improve Prometheus regexp (#8039)
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd authored Oct 14, 2024
1 parent 749378f commit 3541b94
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions alerting/temporal/src/qdrant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -82,6 +89,7 @@ function extractMetricDetails(line: string) {

return { name, labels, value };
}

return null;
}

Expand Down

0 comments on commit 3541b94

Please sign in to comment.