import { css } from '@emotion/css'; import { capitalize } from 'lodash'; import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Badge, CallToActionCard, Card, Icon, LinkButton, Tooltip, useStyles2 } from '@grafana/ui'; import { ExternalDataSourceAM } from '../../hooks/useExternalAmSelector'; import { makeDataSourceLink } from '../../utils/misc'; export interface ExternalAlertManagerDataSourcesProps { alertmanagers: ExternalDataSourceAM[]; inactive: boolean; } export function ExternalAlertmanagerDataSources({ alertmanagers, inactive }: ExternalAlertManagerDataSourcesProps) { const styles = useStyles2(getStyles); return ( <>
Alertmanagers Receiving Grafana-managed alerts
Alertmanager data sources support a configuration setting that allows you to choose to send Grafana-managed alerts to that Alertmanager.
Below, you can see the list of all Alertmanager data sources that have this setting enabled.
{alertmanagers.length === 0 && ( There are no Alertmanager data sources configured to receive Grafana-managed alerts.
You can change this by selecting Receive Grafana Alerts in a data source configuration. } callToActionElement={Go to data sources} className={styles.externalDsCTA} /> )} {alertmanagers.length > 0 && (
{alertmanagers.map((am) => ( ))}
)} ); } interface ExternalAMdataSourceCardProps { alertmanager: ExternalDataSourceAM; inactive: boolean; } export function ExternalAMdataSourceCard({ alertmanager, inactive }: ExternalAMdataSourceCardProps) { const styles = useStyles2(getStyles); const { dataSource, status, statusInconclusive, url } = alertmanager; return ( {dataSource.name}{' '} {statusInconclusive && ( )} {inactive ? ( ) : ( )} {url} Go to datasource ); } export const getStyles = (theme: GrafanaTheme2) => ({ muted: css` font-size: ${theme.typography.bodySmall.fontSize}; line-height: ${theme.typography.bodySmall.lineHeight}; color: ${theme.colors.text.secondary}; `, externalHeading: css` justify-content: flex-start; `, externalWarningIcon: css` margin: ${theme.spacing(0, 1)}; fill: ${theme.colors.warning.main}; `, externalDs: css` display: grid; gap: ${theme.spacing(1)}; padding: ${theme.spacing(2, 0)}; `, externalDsCTA: css` margin: ${theme.spacing(2, 0)}; `, });