UNPKG

@grafana/alerting

Version:

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

34 lines (32 loc) 953 B
"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] } ); } export { findCommonLabels, isPrivateLabel }; //# sourceMappingURL=labels.mjs.map