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/Silences.tsx

39 lines
1.6 KiB

import { InfoBox, LoadingPlaceholder } from '@grafana/ui';
import React, { FC, useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { AlertingPageWrapper } from './components/AlertingPageWrapper';
import { AlertManagerPicker } from './components/AlertManagerPicker';
import { useAlertManagerSourceName } from './hooks/useAlertManagerSourceName';
import { useUnifiedAlertingSelector } from './hooks/useUnifiedAlertingSelector';
import { fetchSilencesAction } from './state/actions';
import { initialAsyncRequestState } from './utils/redux';
const Silences: FC = () => {
const [alertManagerSourceName, setAlertManagerSourceName] = useAlertManagerSourceName();
const dispatch = useDispatch();
const silences = useUnifiedAlertingSelector((state) => state.silences);
useEffect(() => {
dispatch(fetchSilencesAction(alertManagerSourceName));
}, [alertManagerSourceName, dispatch]);
const { result, loading, error } = silences[alertManagerSourceName] || initialAsyncRequestState;
return (
<AlertingPageWrapper pageId="silences">
<AlertManagerPicker current={alertManagerSourceName} onChange={setAlertManagerSourceName} />
<br />
<br />
{error && !loading && (
<InfoBox severity="error" title={<h4>Error loading silences</h4>}>
{error.message || 'Unknown error.'}
</InfoBox>
)}
{loading && <LoadingPlaceholder text="loading silences..." />}
{result && !loading && !error && <pre>{JSON.stringify(result, null, 2)}</pre>}
</AlertingPageWrapper>
);
};
export default Silences;