UNPKG

@grafana/alerting

Version:

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

55 lines (54 loc) 2.55 kB
import { type Receiver } from '@grafana/api-clients/rtkq/notifications.alerting/v0alpha1'; import { type ContactPoint, type ContactPointMetadataAnnotations } from '../api/notifications/v0alpha1/types'; /** * Minimal structural type that any k8s alerting entity satisfies. * Accepts ContactPoint, Receiver, and the app-internal EntityToCheck type alike. */ type WithContactPointAnnotations = { metadata?: { annotations?: ContactPointMetadataAnnotations; }; }; /** * Checks if a contact point can be used in routes and rules. * Contact points that are imported from external sources (e.g., Prometheus Alertmanager) * have the `grafana.com/canUse` annotation set to `false` and cannot be used. * * @param contactPoint - The ContactPoint object to check * @returns `true` if the contact point can be used, `false` otherwise */ export declare function isUsableContactPoint(contactPoint: ContactPoint | Receiver): boolean; /** * Returns the number of notification policy routes that reference this contact point, * as reported by the server-set `grafana.com/inUse/routes` annotation. * Returns 0 when the annotation is absent. */ export declare function getContactPointInUseRoutes(contactPoint: WithContactPointAnnotations): number; /** * Returns the number of alert rules that reference this contact point via simplified routing, * as reported by the server-set `grafana.com/inUse/rules` annotation. * Returns 0 when the annotation is absent. */ export declare function getContactPointInUseRules(contactPoint: WithContactPointAnnotations): number; /** * Returns how many routes and rules currently reference this contact point, * as reported by the server-set in-use annotations. * * @returns `{ routes, rules }` — each count is 0 when the annotation is absent. */ export declare function getContactPointInUse(contactPoint: WithContactPointAnnotations): { routes: number; rules: number; }; /** * Generates a human-readable description of a ContactPoint by summarizing its integrations. * If the ContactPoint has no integrations, it returns an empty placeholder text. * * For integrations, it counts the occurrences of each type and formats them as a comma-separated list. * Multiple integrations of the same type are indicated with a count in parentheses. * * @param contactPoint - The ContactPoint object to describe * @returns A string description of the ContactPoint's integrations */ export declare function getContactPointDescription(contactPoint: ContactPoint | Receiver): string; export {};