UNPKG

@grafana/alerting

Version:

Grafana Alerting Library – Build vertical integrations on top of the industry-leading alerting solution

39 lines (35 loc) 1.07 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); "use strict"; const GRAFANA_ORIGIN_LABEL = "__grafana_origin"; function isPrivateLabelKey(labelKey) { return labelKey.startsWith("__") && labelKey.endsWith("__") || labelKey === GRAFANA_ORIGIN_LABEL; } const isPrivateLabel = ([key, _]) => isPrivateLabelKey(key); function findCommonLabels(labelSets) { if (!Array.isArray(labelSets) || labelSets.length === 0) { return {}; } return labelSets.reduce( (acc, labels) => { if (!labels) { throw new Error("Need parsed labels to find common labels."); } Object.keys(labels).forEach((key) => { if (acc[key] === void 0 || acc[key] !== labels[key]) { delete acc[key]; } }); Object.keys(acc).forEach((key) => { if (labels[key] === void 0) { delete acc[key]; } }); return acc; }, { ...labelSets[0] } ); } exports.findCommonLabels = findCommonLabels; exports.isPrivateLabel = isPrivateLabel; //# sourceMappingURL=labels.cjs.map