The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/alerting/unified/components/silences/SilenceGrafanaRuleDrawer.tsx

52 lines
1.8 KiB

import React from 'react';
import { Divider, Drawer, Stack } from '@grafana/ui';
import { AlertManagerPicker } from 'app/features/alerting/unified/components/AlertManagerPicker';
import { GrafanaAlertmanagerDeliveryWarning } from 'app/features/alerting/unified/components/GrafanaAlertmanagerDeliveryWarning';
import { SilencesEditor } from 'app/features/alerting/unified/components/silences/SilencesEditor';
import { getDefaultSilenceFormValues } from 'app/features/alerting/unified/components/silences/utils';
import { useAlertmanager } from 'app/features/alerting/unified/state/AlertmanagerContext';
import { RulerGrafanaRuleDTO } from 'app/types/unified-alerting-dto';
type Props = {
rulerRule: RulerGrafanaRuleDTO;
onClose: () => void;
};
/**
* For a given Grafana managed rule, renders a drawer containing silences editor and Alertmanager selection
*/
const SilenceGrafanaRuleDrawer = ({ rulerRule, onClose }: Props) => {
const { uid } = rulerRule.grafana_alert;
const formValues = getDefaultSilenceFormValues();
const { selectedAlertmanager } = useAlertmanager();
return (
<Drawer
title="Silence alert rule"
subtitle="Configure silences to stop notifications from a particular alert rule."
onClose={onClose}
size="md"
>
<Stack direction={'column'}>
<GrafanaAlertmanagerDeliveryWarning currentAlertmanager={selectedAlertmanager!} />
<div>
<AlertManagerPicker showOnlyReceivingGrafanaAlerts />
<Divider />
</div>
<SilencesEditor
ruleUid={uid}
formValues={formValues}
alertManagerSourceName={selectedAlertmanager!}
onSilenceCreated={onClose}
onCancel={onClose}
/>
</Stack>
</Drawer>
);
};
export default SilenceGrafanaRuleDrawer;