@grafana/alerting
Version:
Grafana Alerting Library – Build vertical integrations on top of the industry-leading alerting solution
53 lines (52 loc) • 2.66 kB
TypeScript
import { type RoutingTree } from '@grafana/api-clients/rtkq/notifications.alerting/v0alpha1';
import { type Label } from '../matchers/types';
import { type LabelMatchDetails } from '../matchers/utils';
import { type Route, type RouteWithID } from './types';
export declare const INHERITABLE_KEYS: readonly ["receiver", "group_by", "group_wait", "group_interval", "repeat_interval"];
type InheritableKeys = typeof INHERITABLE_KEYS;
export type InheritableProperties = Pick<Route, InheritableKeys[number]>;
export type RouteMatchInfo<T extends Route> = {
route: T;
matchDetails: LabelMatchDetails[];
matched: boolean;
};
export interface RouteMatchResult<T extends Route> {
route: T;
labels: Label[];
matchingJourney: Array<RouteMatchInfo<T>>;
}
/**
* This function performs a depth-first left-to-right search through the route tree and returns the matching routing nodes.
*
* If the current node is not a match, return nothing
* Normalization should have happened earlier in the code
*/
export declare function findMatchingRoutes<T extends Route>(route: T, labels: Label[], matchingJourney?: Array<RouteMatchInfo<T>>): Array<RouteMatchResult<T>>;
/**
* This function will compute the full tree with inherited properties – this is mostly used for search and filtering
*/
export declare function computeInheritedTree<T extends Route>(parent: T): T;
export declare function getInheritedProperties<T extends Route>(parentRoute: T, childRoute: T, propertiesParentInherited?: InheritableProperties): InheritableProperties;
export declare function addUniqueIdentifier(route: Route): RouteWithID;
export type TreeMatch = {
expandedTree: RouteWithID;
matchedPolicies: Map<RouteWithID, Array<RouteMatchResult<RouteWithID>>>;
};
/**
* This function will return what notification policies would match a set of labels.
*
* ⚠️ This function is rather CPU intensive depending on both the size of the labels list and the size of the notification policy tree.
* When using this function, consider wrapping it in a web-worker to offload this from the main JavaScript thread.
*
* @param instances - A set of labels for which you want to determine the matching policies
* @param routingTree - A notification policy tree (or subtree)
*/
export declare function matchInstancesToRoute(rootRoute: Route, instances: Label[][]): TreeMatch;
/**
* Converts a RoutingTree to a Route by merging defaults with routes.
*
* @param routingTree - The RoutingTree from the API
* @returns A Route that can be used with the matching functions
*/
export declare function convertRoutingTreeToRoute(routingTree: RoutingTree): Route;
export {};