From bea62aa6150344439c30026b39253d6bf6da48e4 Mon Sep 17 00:00:00 2001 From: Rares Mardare Date: Wed, 5 Feb 2025 10:58:19 +0200 Subject: [PATCH] Alerting: Update IRM copies in Configuration Tracker (#100069) * updated alerting configuration tracker with new IRM copies * Configuration tracker steps * copy * CI trigger --------- Co-authored-by: Sonia Aguilar --- .../gops/configuration-tracker/irmHooks.ts | 362 +++++++++++------- 1 file changed, 215 insertions(+), 147 deletions(-) diff --git a/public/app/features/gops/configuration-tracker/irmHooks.ts b/public/app/features/gops/configuration-tracker/irmHooks.ts index 1f02021aff6..76c738e80f3 100644 --- a/public/app/features/gops/configuration-tracker/irmHooks.ts +++ b/public/app/features/gops/configuration-tracker/irmHooks.ts @@ -6,6 +6,7 @@ import { useNotificationPolicyRoute } from 'app/features/alerting/unified/compon import { getIrmIfPresentOrIncidentPluginId, getIrmIfPresentOrOnCallPluginId, + getIsIrmPluginPresent, } from 'app/features/alerting/unified/utils/config'; import { GRAFANA_RULES_SOURCE_NAME } from 'app/features/alerting/unified/utils/datasource'; import { RelativeUrl, createRelativeUrl } from 'app/features/alerting/unified/utils/url'; @@ -125,175 +126,242 @@ export function useGetEssentialsConfiguration(): EssentialsConfigurationData { locationService.push(urlToGoWithIntegration); } + function getGrafanaAlertingConfigSteps(): SectionDtoStep[] { + let steps: SectionDtoStep[] = [ + { + title: 'Update default contact point', + description: 'Update the default contact point to a method other than the example email address.', + button: { + type: 'openLink', + urlLink: { + url: `/alerting/notifications`, + queryParams: { search: defaultContactpoint, alertmanager: 'grafana' }, + }, + label: 'Edit', + labelOnDone: 'View', + urlLinkOnDone: { + url: `/alerting/notifications`, + }, + }, + done: isContactPointReady(defaultContactpoint, contactPoints), + }, + ]; + + if (!getIsIrmPluginPresent()) { + steps = [ + ...steps, + { + title: 'Connect alerting to OnCall', + description: 'Create an OnCall integration for an alerting contact point.', + button: { + type: 'openLink', + urlLink: { + url: '/alerting/notifications/receivers/new', + }, + label: 'Connect', + urlLinkOnDone: { + url: '/alerting/notifications', + }, + labelOnDone: 'View', + }, + done: isOnCallContactPointReady(contactPoints), + }, + ]; + } + + steps = [ + ...steps, + { + title: 'Create alert rule', + description: 'Create an alert rule to monitor your system.', + button: { + type: 'openLink', + urlLink: { + url: '/alerting/new', + }, + label: 'Create', + urlLinkOnDone: { + url: '/alerting/list', + }, + labelOnDone: 'View', + }, + done: isCreateAlertRuleDone, + }, + { + title: 'Create SLO', + description: 'Create SLOs to monitor your service.', + button: { + type: 'openLink', + urlLink: { + url: '/a/grafana-slo-app/wizard/new', + }, + label: 'Create', + urlLinkOnDone: { + url: '/a/grafana-slo-app/manage-slos', + }, + labelOnDone: 'View', + }, + done: hasSlo, + }, + { + title: 'Enable SLO alerting', + description: 'Configure SLO alerting to receive notifications when your SLOs are breached.', + button: { + type: 'openLink', + urlLink: { + queryParams: { alertsEnabled: 'disabled' }, + url: '/a/grafana-slo-app/manage-slos', + }, + label: 'Enable', + urlLinkOnDone: { + queryParams: { alertsEnabled: 'enabled' }, + url: '/a/grafana-slo-app/manage-slos', + }, + labelOnDone: 'View', + }, + done: hasSloWithAlert, + }, + ]; + + return steps; + } + const essentialContent: SectionsDto = { sections: [ { title: 'Detect', description: 'Configure Grafana Alerting', - steps: [ - { - title: 'Update default contact point', - description: 'Update the default contact point to a method other than the example email address.', - button: { - type: 'openLink', - urlLink: { - url: `/alerting/notifications`, - queryParams: { search: defaultContactpoint, alertmanager: 'grafana' }, - }, - label: 'Edit', - labelOnDone: 'View', - urlLinkOnDone: { - url: `/alerting/notifications`, - }, - }, - done: isContactPointReady(defaultContactpoint, contactPoints), - }, - { - title: 'Connect alerting to OnCall', - description: 'Create an OnCall integration for an alerting contact point.', - button: { - type: 'openLink', - urlLink: { - url: '/alerting/notifications/receivers/new', - }, - label: 'Connect', - urlLinkOnDone: { - url: '/alerting/notifications', - }, - labelOnDone: 'View', - }, - done: isOnCallContactPointReady(contactPoints), - }, - { - title: 'Create alert rule', - description: 'Create an alert rule to monitor your system.', - button: { - type: 'openLink', - urlLink: { - url: '/alerting/new', - }, - label: 'Create', - urlLinkOnDone: { - url: '/alerting/list', - }, - labelOnDone: 'View', - }, - done: isCreateAlertRuleDone, - }, - { - title: 'Create your first SLO', - description: 'Create SLOs to monitor your service.', - button: { - type: 'openLink', - urlLink: { - url: '/a/grafana-slo-app/wizard/new', - }, - label: 'Create', - urlLinkOnDone: { - url: '/a/grafana-slo-app/manage-slos', - }, - labelOnDone: 'View', - }, - done: hasSlo, - }, - { - title: 'Enable SLO alerting', - description: 'Configure SLO alerting to receive notifications when your SLOs are breached.', - button: { - type: 'openLink', - urlLink: { - queryParams: { alertsEnabled: 'disabled' }, - url: '/a/grafana-slo-app/manage-slos', - }, - label: 'Enable', - urlLinkOnDone: { - queryParams: { alertsEnabled: 'enabled' }, - url: '/a/grafana-slo-app/manage-slos', - }, - labelOnDone: 'View', - }, - done: hasSloWithAlert, - }, - ], + steps: getGrafanaAlertingConfigSteps(), }, { title: 'Respond', description: 'Configure OnCall and Incident', - steps: [ - { - title: 'Initialize Incident plugin', - description: 'Initialize the Incident plugin to declare and manage incidents.', - button: { - type: 'openLink', - urlLink: { - url: `/a/${getIrmIfPresentOrIncidentPluginId()}/walkthrough/generate-key`, + steps: getIsIrmPluginPresent() + ? [ + { + title: 'Connect alerting to IRM', + description: 'Create an IRM integration for an alerting contact point.', + button: { + type: 'openLink', + urlLink: { + url: '/alerting/notifications/receivers/new', + }, + label: 'Connect', + urlLinkOnDone: { + url: '/alerting/notifications', + }, + labelOnDone: 'View', + }, + done: isOnCallContactPointReady(contactPoints), }, - label: 'Initialize', - urlLinkOnDone: { - url: `/a/${getIrmIfPresentOrIncidentPluginId()}`, + { + title: 'Connect IRM to your Slack workspace', + description: + 'Receive alerts and oncall notifications, or automatically create an incident channel and manage incidents directly within your chat environment.', + button: { + type: 'openLink', + urlLink: { + url: `/a/${getIrmIfPresentOrIncidentPluginId()}/integrations/grate.slack`, + }, + label: 'Connect', + urlLinkOnDone: { + url: `/a/${getIrmIfPresentOrIncidentPluginId()}/integrations`, + }, + }, + done: isChatOpsInstalled, }, - labelOnDone: 'View', - }, - done: isIncidentsInstalled, - }, - { - title: 'Connect your Messaging workspace to OnCall', - description: 'Receive alerts and oncall notifications within your chat environment.', - button: { - type: 'openLink', - urlLink: { - url: `/a/${getIrmIfPresentOrOnCallPluginId()}/settings`, - queryParams: { tab: 'ChatOps', chatOpsTab: 'Slack' }, + { + title: 'Add Slack notifications to IRM integrations', + description: 'Select ChatOps channels to route notifications', + button: { + type: 'openLink', + urlLink: { + url: `/a/${getIrmIfPresentOrOnCallPluginId()}/integrations/`, + }, + label: 'Add', + urlLinkOnDone: { + url: `/a/${getIrmIfPresentOrOnCallPluginId()}/integrations/`, + }, + labelOnDone: 'View', + }, + done: is_integration_chatops_connected, }, - label: 'Connect', - urlLinkOnDone: { - url: `/a/${getIrmIfPresentOrOnCallPluginId()}/settings`, - queryParams: { tab: 'ChatOps' }, + ] + : [ + { + title: 'Initialize Incident plugin', + description: 'Initialize the Incident plugin to declare and manage incidents.', + button: { + type: 'openLink', + urlLink: { + url: `/a/${getIrmIfPresentOrIncidentPluginId()}/walkthrough/generate-key`, + }, + label: 'Initialize', + urlLinkOnDone: { + url: `/a/${getIrmIfPresentOrIncidentPluginId()}`, + }, + labelOnDone: 'View', + }, + done: isIncidentsInstalled, }, - labelOnDone: 'View', - }, - done: is_chatops_connected, - }, - { - title: 'Connect your Messaging workspace to Incident', - description: - 'Automatically create an incident channel and manage incidents directly within your chat environment.', - button: { - type: 'openLink', - urlLink: { - url: `/a/${getIrmIfPresentOrIncidentPluginId()}/integrations/grate.slack`, + { + title: 'Connect your Messaging workspace to OnCall', + description: 'Receive alerts and oncall notifications within your chat environment.', + button: { + type: 'openLink', + urlLink: { + url: `/a/${getIrmIfPresentOrOnCallPluginId()}/settings`, + queryParams: { tab: 'ChatOps', chatOpsTab: 'Slack' }, + }, + label: 'Connect', + urlLinkOnDone: { + url: `/a/${getIrmIfPresentOrOnCallPluginId()}/settings`, + queryParams: { tab: 'ChatOps' }, + }, + labelOnDone: 'View', + }, + done: is_chatops_connected, }, - label: 'Connect', - urlLinkOnDone: { - url: `/a/${getIrmIfPresentOrIncidentPluginId()}/integrations`, + { + title: 'Connect your Messaging workspace to Incident', + description: + 'Automatically create an incident channel and manage incidents directly within your chat environment.', + button: { + type: 'openLink', + urlLink: { + url: `/a/${getIrmIfPresentOrIncidentPluginId()}/integrations/grate.slack`, + }, + label: 'Connect', + urlLinkOnDone: { + url: `/a/${getIrmIfPresentOrIncidentPluginId()}/integrations`, + }, + }, + done: isChatOpsInstalled, }, - }, - done: isChatOpsInstalled, - }, - { - title: 'Add Messaging workspace channel to OnCall Integration', - description: 'Select ChatOps channels to route notifications', - button: { - type: 'openLink', - urlLink: { - url: `/a/${getIrmIfPresentOrOnCallPluginId()}/integrations/`, + { + title: 'Add Messaging workspace channel to OnCall Integration', + description: 'Select ChatOps channels to route notifications', + button: { + type: 'openLink', + urlLink: { + url: `/a/${getIrmIfPresentOrOnCallPluginId()}/integrations/`, + }, + label: 'Add', + urlLinkOnDone: { + url: `/a/${getIrmIfPresentOrOnCallPluginId()}/integrations/`, + }, + labelOnDone: 'View', + }, + done: is_integration_chatops_connected, }, - label: 'Add', - urlLinkOnDone: { - url: `/a/${getIrmIfPresentOrOnCallPluginId()}/integrations/`, - }, - labelOnDone: 'View', - }, - done: is_integration_chatops_connected, - }, - ], + ], }, { title: 'Test your configuration', description: '', steps: [ { - title: 'Send OnCall demo alert via Alerting integration', + title: getIsIrmPluginPresent() ? 'Send test alert' : 'Send OnCall demo alert via Alerting integration', description: 'In the integration page, click Send demo alert, to review your notification', button: { type: 'dropDown',