diff --git a/public/app/features/alerting/unified/components/contact-points/ContactPoint.tsx b/public/app/features/alerting/unified/components/contact-points/ContactPoint.tsx
index 1d671c25c21..f8b353a1059 100644
--- a/public/app/features/alerting/unified/components/contact-points/ContactPoint.tsx
+++ b/public/app/features/alerting/unified/components/contact-points/ContactPoint.tsx
@@ -39,7 +39,7 @@ export const ContactPoint = ({
const styles = useStyles2(getStyles);
// TODO probably not the best way to figure out if we want to show either only the summary or full metadata for the receivers?
- const showFullMetadata = receivers.some((receiver) => Boolean(receiver[RECEIVER_STATUS_KEY]));
+ const showFullMetadata = receivers.some((receiver) => Boolean(receiver[RECEIVER_META_KEY]));
return (
diff --git a/public/app/features/alerting/unified/components/contact-points/useContactPoints.tsx b/public/app/features/alerting/unified/components/contact-points/useContactPoints.tsx
index f5c9dbd14a1..c661ead47f0 100644
--- a/public/app/features/alerting/unified/components/contact-points/useContactPoints.tsx
+++ b/public/app/features/alerting/unified/components/contact-points/useContactPoints.tsx
@@ -11,6 +11,7 @@ import {
ComGithubGrafanaGrafanaPkgApisAlertingNotificationsV0Alpha1Receiver,
generatedReceiversApi,
} from 'app/features/alerting/unified/openapi/receiversApi.gen';
+import { cloudNotifierTypes } from 'app/features/alerting/unified/utils/cloud-alertmanager-notifier-types';
import { GRAFANA_RULES_SOURCE_NAME } from 'app/features/alerting/unified/utils/datasource';
import { getNamespace, shouldUseK8sApi } from 'app/features/alerting/unified/utils/k8s/utils';
@@ -175,7 +176,7 @@ export function useContactPointsWithStatus() {
contactPoints: result.data
? enhanceContactPointsWithMetadata(
fetchContactPointsStatus.data,
- fetchReceiverMetadata.data,
+ isGrafanaAlertmanager ? fetchReceiverMetadata.data : cloudNotifierTypes,
onCallMetadata,
result.data.alertmanager_config.receivers ?? [],
result.data
diff --git a/public/app/features/alerting/unified/components/contact-points/utils.ts b/public/app/features/alerting/unified/components/contact-points/utils.ts
index 7f9d460b606..1fe8c162a20 100644
--- a/public/app/features/alerting/unified/components/contact-points/utils.ts
+++ b/public/app/features/alerting/unified/components/contact-points/utils.ts
@@ -34,13 +34,14 @@ export function getReceiverDescription(receiver: ReceiverConfigWithMetadata): Re
if (!receiver.settings) {
return undefined;
}
+ const { settings } = receiver;
switch (receiver.type) {
case 'email': {
- const hasEmailAddresses = 'addresses' in receiver.settings; // when dealing with alertmanager email_configs we don't normalize the settings
- return hasEmailAddresses ? summarizeEmailAddresses(receiver.settings['addresses']) : undefined;
+ const addresses = settings.addresses || settings.to; // when dealing with alertmanager email_configs we don't normalize the settings
+ return addresses ? summarizeEmailAddresses(addresses) : undefined;
}
case 'slack': {
- const recipient: string | undefined = receiver.settings['recipient'];
+ const recipient = settings.recipient || settings.channel;
if (!recipient) {
return;
}
@@ -50,12 +51,10 @@ export function getReceiverDescription(receiver: ReceiverConfigWithMetadata): Re
return `#${channelName}`;
}
case 'kafka': {
- const topicName: string | undefined = receiver.settings['kafkaTopic'];
- return topicName;
+ return settings.kafkaTopic;
}
case 'webhook': {
- const url: string | undefined = receiver.settings['url'];
- return url;
+ return settings.url;
}
case ReceiverTypes.OnCall: {
return receiver[RECEIVER_PLUGIN_META_KEY]?.description;
@@ -123,11 +122,7 @@ export function enhanceContactPointsWithMetadata(
const usedContactPoints = getUsedContactPoints(fullyInheritedTree);
const usedContactPointsByName = groupBy(usedContactPoints, 'receiver');
- const contactPointsList = alertmanagerConfiguration
- ? (alertmanagerConfiguration?.alertmanager_config.receivers ?? [])
- : (contactPoints ?? []);
-
- const enhanced = contactPointsList.map((contactPoint) => {
+ const enhanced = contactPoints.map((contactPoint) => {
const receivers = extractReceivers(contactPoint);
const statusForReceiver = status.find((status) => status.name === contactPoint.name);
diff --git a/public/app/features/alerting/unified/utils/receivers.ts b/public/app/features/alerting/unified/utils/receivers.ts
index d4147cae3d1..9d9c88c960a 100644
--- a/public/app/features/alerting/unified/utils/receivers.ts
+++ b/public/app/features/alerting/unified/utils/receivers.ts
@@ -1,4 +1,4 @@
-import { isEmpty, times } from 'lodash';
+import { isEmpty } from 'lodash';
import { GrafanaManagedReceiverConfig, Receiver } from 'app/plugins/datasource/alertmanager/types';
@@ -12,10 +12,14 @@ import { GrafanaManagedReceiverConfig, Receiver } from 'app/plugins/datasource/a
* We don't normalize the configuration settings and those are blank for vanilla Alertmanager receivers.
*
* Example input:
- * { name: 'my receiver', email_configs: [{ from: "foo@bar.com" }] }
+ * ```
+ * { name: 'my receiver', email_configs: [{ from: "foo@bar.com" }] }
+ * ```
*
* Example output:
- * { name: 'my receiver', grafana_managed_receiver_configs: [{ type: 'email', settings: {} }] }
+ * ```
+ * { name: 'my receiver', grafana_managed_receiver_configs: [{ type: 'email', settings: {} }] }
+ * ```
*/
export function extractReceivers(receiver: Receiver): GrafanaManagedReceiverConfig[] {
if ('grafana_managed_receiver_configs' in receiver) {
@@ -27,13 +31,14 @@ export function extractReceivers(receiver: Receiver): GrafanaManagedReceiverConf
.filter(([_, value]) => Array.isArray(value) && !isEmpty(value))
.reduce((acc: GrafanaManagedReceiverConfig[], [key, value]) => {
const type = key.replace('_configs', '');
-
- const configs = times(value.length, () => ({
- name: receiver.name,
- type: type,
- settings: [], // we don't normalize the configuration values
- disableResolveMessage: false,
- }));
+ const configs = value.map((settings: unknown) => {
+ return {
+ name: receiver.name,
+ type,
+ settings,
+ disableResolveMessage: false,
+ };
+ });
return acc.concat(configs);
}, []);