Alerting: Matching instances preview for notification policies (#68882)

* Basic implementation in web worker

* Move instances discovery to the worker

* Remove filtering from the worker

* Use normalized routes, use rtk query for alert groups fetching

* Reorganize matchers utilities to be available for web workers

* Move object matchers to the machers util file, rename worker

* Move worker code to a separate hook, add perf logging

* Add a mock for the web worker code, fix tests

* Fix tests warnings

* Remove notification policy feature flag

* Add normalizeRoute tests, change the regex match to test for label matching

* Move worker init to the file scope

* Simplify useAsyncFn hook

* Use CorsWorker as a workaround for web workers loading from CDN

* Use a feature flag to enable/disable worker-based preview, add worker error handling

* Add POC for react-enable working with grafana feature toggles

* Code cleanup

* Remove console error, add useRouteGroupsMatcher tests

* Fix tests mock
This commit is contained in:
Konrad Lalik
2023-05-30 15:15:22 +02:00
committed by GitHub
parent 0d54a8858b
commit 2f0728ac67
25 changed files with 555 additions and 226 deletions
+8
View File
@@ -435,6 +435,14 @@ var (
State: FeatureStateAlpha,
Owner: grafanaAlertingSquad,
},
{
Name: "alertingNotificationsPoliciesMatchingInstances",
Description: "Enables the preview of matching instances for notification policies",
State: FeatureStateStable,
FrontendOnly: true,
Expression: "true", // enabled by default
Owner: grafanaAlertingSquad,
},
{
Name: "alertStateHistoryLokiPrimary",
Description: "Enable a remote Loki instance as the primary source for state history reads.",
+1
View File
@@ -63,6 +63,7 @@ lokiMetricDataplane,stable,@grafana/observability-logs,false,false,false,false
dataplaneFrontendFallback,stable,@grafana/observability-metrics,false,false,false,true
disableSSEDataplane,alpha,@grafana/observability-metrics,false,false,false,false
alertStateHistoryLokiSecondary,alpha,@grafana/alerting-squad,false,false,false,false
alertingNotificationsPoliciesMatchingInstances,stable,@grafana/alerting-squad,false,false,false,true
alertStateHistoryLokiPrimary,alpha,@grafana/alerting-squad,false,false,false,false
alertStateHistoryLokiOnly,alpha,@grafana/alerting-squad,false,false,false,false
unifiedRequestLog,alpha,@grafana/backend-platform,false,false,false,false
1 Name State Owner requiresDevMode RequiresLicense RequiresRestart FrontendOnly
63 dataplaneFrontendFallback stable @grafana/observability-metrics false false false true
64 disableSSEDataplane alpha @grafana/observability-metrics false false false false
65 alertStateHistoryLokiSecondary alpha @grafana/alerting-squad false false false false
66 alertingNotificationsPoliciesMatchingInstances stable @grafana/alerting-squad false false false true
67 alertStateHistoryLokiPrimary alpha @grafana/alerting-squad false false false false
68 alertStateHistoryLokiOnly alpha @grafana/alerting-squad false false false false
69 unifiedRequestLog alpha @grafana/backend-platform false false false false
+4
View File
@@ -263,6 +263,10 @@ const (
// Enable Grafana to write alert state history to an external Loki instance in addition to Grafana annotations.
FlagAlertStateHistoryLokiSecondary = "alertStateHistoryLokiSecondary"
// FlagAlertingNotificationsPoliciesMatchingInstances
// Enables the preview of matching instances for notification policies
FlagAlertingNotificationsPoliciesMatchingInstances = "alertingNotificationsPoliciesMatchingInstances"
// FlagAlertStateHistoryLokiPrimary
// Enable a remote Loki instance as the primary source for state history reads.
FlagAlertStateHistoryLokiPrimary = "alertStateHistoryLokiPrimary"