diff --git a/public/app/features/alerting/routes.tsx b/public/app/features/alerting/routes.tsx
index 04c8fd63e44..e7e90f9c5ab 100644
--- a/public/app/features/alerting/routes.tsx
+++ b/public/app/features/alerting/routes.tsx
@@ -77,6 +77,8 @@ export function getAlertingRoutes(cfg = config): RouteDescriptor[] {
roles: evaluateAccess([
AccessControlAction.AlertingInstanceCreate,
AccessControlAction.AlertingInstancesExternalWrite,
+ AccessControlAction.AlertingSilenceCreate,
+ AccessControlAction.AlertingSilenceUpdate,
]),
component: importAlertingComponent(
() => import(/* webpackChunkName: "AlertSilences" */ 'app/features/alerting/unified/Silences')
diff --git a/public/app/features/alerting/unified/Silences.test.tsx b/public/app/features/alerting/unified/Silences.test.tsx
index a0e6303c1e3..68054e1744e 100644
--- a/public/app/features/alerting/unified/Silences.test.tsx
+++ b/public/app/features/alerting/unified/Silences.test.tsx
@@ -12,6 +12,7 @@ import {
} from 'app/features/alerting/unified/mocks/server/handlers/datasources';
import { MOCK_GRAFANA_ALERT_RULE_TITLE } from 'app/features/alerting/unified/mocks/server/handlers/grafanaRuler';
import { silenceCreateHandler } from 'app/features/alerting/unified/mocks/server/handlers/silences';
+import { MATCHER_ALERT_RULE_UID } from 'app/features/alerting/unified/utils/constants';
import { MatcherOperator, SilenceState } from 'app/plugins/datasource/alertmanager/types';
import { AccessControlAction } from 'app/types';
@@ -339,6 +340,11 @@ describe('Silence create/edit', () => {
expect(await screen.findByLabelText(/alert rule/i)).toHaveValue(grafanaRulerRule.grafana_alert.title);
});
+ it('populates form with information when specifying alert rule UID in matchers', async () => {
+ renderSilences(`/alerting/silence/new?matcher=${MATCHER_ALERT_RULE_UID}%3D${grafanaRulerRule.grafana_alert.uid}`);
+ expect(await screen.findByLabelText(/alert rule/i)).toHaveValue(grafanaRulerRule.grafana_alert.title);
+ });
+
it(
'silences page should contain alertmanager parameter after creating a silence',
async () => {
diff --git a/public/app/features/alerting/unified/Silences.tsx b/public/app/features/alerting/unified/Silences.tsx
index fc8fd0c8ea4..c9a2cd10af7 100644
--- a/public/app/features/alerting/unified/Silences.tsx
+++ b/public/app/features/alerting/unified/Silences.tsx
@@ -5,6 +5,8 @@ import {
defaultsFromQuery,
getDefaultSilenceFormValues,
} from 'app/features/alerting/unified/components/silences/utils';
+import { MATCHER_ALERT_RULE_UID } from 'app/features/alerting/unified/utils/constants';
+import { parseQueryParamMatchers } from 'app/features/alerting/unified/utils/matchers';
import { AlertmanagerPageWrapper } from './components/AlertingPageWrapper';
import { GrafanaAlertmanagerDeliveryWarning } from './components/GrafanaAlertmanagerDeliveryWarning';
@@ -30,9 +32,22 @@ const Silences = () => {
{({ location }) => {
const queryParams = new URLSearchParams(location.search);
+
+ const potentialAlertRuleMatcher = parseQueryParamMatchers(queryParams.getAll('matcher')).find(
+ (m) => m.name === MATCHER_ALERT_RULE_UID
+ );
+
+ const potentialRuleUid = potentialAlertRuleMatcher?.value;
+
const formValues = getDefaultSilenceFormValues(defaultsFromQuery(queryParams));
- return ;
+ return (
+
+ );
}}
diff --git a/public/app/features/alerting/unified/components/silences/utils.ts b/public/app/features/alerting/unified/components/silences/utils.ts
index fd111bbbec5..8c8088b9db8 100644
--- a/public/app/features/alerting/unified/components/silences/utils.ts
+++ b/public/app/features/alerting/unified/components/silences/utils.ts
@@ -2,6 +2,7 @@ import { DefaultTimeZone, addDurationToDate, dateTime, intervalToAbbreviatedDura
import { config } from '@grafana/runtime';
import { SilenceFormFields } from 'app/features/alerting/unified/types/silence-form';
import { matcherToMatcherField } from 'app/features/alerting/unified/utils/alertmanager';
+import { MATCHER_ALERT_RULE_UID } from 'app/features/alerting/unified/utils/constants';
import { parseQueryParamMatchers } from 'app/features/alerting/unified/utils/matchers';
import { MatcherOperator, Silence } from 'app/plugins/datasource/alertmanager/types';
@@ -14,7 +15,9 @@ export const defaultsFromQuery = (searchParams: URLSearchParams): Partial !m.startsWith(MATCHER_ALERT_RULE_UID));
+
+ const formMatchers = parseQueryParamMatchers(strippedMatchers);
if (formMatchers.length) {
defaults.matchers = formMatchers.map(matcherToMatcherField);
}