MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parseLabels

Function parseLabels

src/environmentd/src/http/static/js/prometheus.js:278–287  ·  view source on GitHub ↗

* Parse a Prometheus label string into key-value pairs. * * @param {string} str - e.g. 'method="GET",status="200"' * @returns {Labels}

(str)

Source from the content-addressed store, hash-verified

276 * @returns {Labels}
277 */
278function parseLabels(str) {
279 /** @type {Labels} */
280 const labels = {};
281 if (!str) return labels;
282 const re = /(\w+)="([^"]*)"/g;
283 for (const m of str.matchAll(re)) {
284 labels[m[1]] = m[2];
285 }
286 return labels;
287}
288
289/**
290 * Extract the grouping prefix from a metric name.

Callers 2

prometheus.spec.tsFile · 0.85
parseSampleLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected