UNPKG

@grafana/alerting

Version:

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

61 lines (58 loc) 2.59 kB
import { faker } from '@faker-js/faker'; import { Factory } from 'fishery'; import { API_GROUP, API_VERSION } from '@grafana/api-clients/rtkq/notifications.alerting/v0alpha1'; import { DEFAULT_NAMESPACE, generateResourceVersion } from '../../../../../mocks/util.mjs'; import { USER_DEFINED_TREE_NAME } from '../../../../../notificationPolicies/consts.mjs'; "use strict"; const LabelMatcherFactory = Factory.define(() => { const operators = ["=", "!=", "=~", "!~"]; return { label: faker.helpers.arrayElement(["service", "env", "team", "severity", "region", "instance"]), type: faker.helpers.arrayElement(operators), value: faker.helpers.arrayElement(["web", "api", "prod", "staging", "critical", "warning", "us-east", "us-west"]) }; }); const RouteFactory = Factory.define(() => ({ continue: faker.datatype.boolean(), receiver: faker.helpers.arrayElement(["web-team", "api-team", "critical-alerts", "dev-team"]), matchers: LabelMatcherFactory.buildList(faker.number.int({ min: 1, max: 3 })), group_by: faker.helpers.arrayElements(["alertname", "service", "severity"], { min: 1, max: 2 }), group_wait: faker.helpers.arrayElement(["10s", "30s", "1m"]), group_interval: faker.helpers.arrayElement(["5m", "10m", "15m"]), repeat_interval: faker.helpers.arrayElement(["1h", "4h", "12h"]), active_time_intervals: faker.helpers.arrayElements(["business-hours", "weekends", "maintenance"], { min: 1, max: 2 }), mute_time_intervals: faker.helpers.arrayElements(["lunch-break", "night-hours"], { min: 1, max: 2 }), routes: [] })); const RoutingTreeFactory = Factory.define(({ sequence }) => { const name = sequence === 1 ? USER_DEFINED_TREE_NAME : `policy-tree-${sequence}`; return { kind: "RoutingTree", apiVersion: `${API_GROUP}/${API_VERSION}`, metadata: { name, namespace: DEFAULT_NAMESPACE, resourceVersion: generateResourceVersion() }, spec: { defaults: { receiver: faker.helpers.arrayElement(["web-team", "api-team", "critical-alerts", "dev-team"]), group_by: ["alertname"], group_wait: "30s", group_interval: "5m", repeat_interval: "4h" }, routes: [] } }; }); const ListRoutingTreeApiResponseFactory = Factory.define(() => ({ kind: "RoutingTreeList", apiVersion: `${API_GROUP}/${API_VERSION}`, metadata: { resourceVersion: generateResourceVersion() }, items: RoutingTreeFactory.buildList(3) })); export { LabelMatcherFactory, ListRoutingTreeApiResponseFactory, RouteFactory, RoutingTreeFactory }; //# sourceMappingURL=Routes.mjs.map