diff --git a/lib/towerops/workers/alert_notification_worker.ex b/lib/towerops/workers/alert_notification_worker.ex
index 62c9b4de..8fb1d0a5 100644
--- a/lib/towerops/workers/alert_notification_worker.ex
+++ b/lib/towerops/workers/alert_notification_worker.ex
@@ -25,14 +25,7 @@ defmodule Towerops.Workers.AlertNotificationWorker do
pd_result =
if routing in ["pagerduty", "both"] do
- case Notifier.notify_trigger(alert, device) do
- {:error, :not_configured} ->
- Logger.debug("PagerDuty not configured for alert #{alert_id}, skipping")
- :ok
-
- result ->
- result
- end
+ notify_pagerduty_trigger(alert, device, alert_id)
else
:ok
end
@@ -65,14 +58,7 @@ defmodule Towerops.Workers.AlertNotificationWorker do
if routing in ["builtin", "both"], do: maybe_acknowledge_incident(alert)
if routing in ["pagerduty", "both"] do
- case Notifier.notify_acknowledge(alert) do
- {:error, :not_configured} ->
- Logger.debug("PagerDuty not configured for alert #{alert_id}, skipping")
- :ok
-
- result ->
- result
- end
+ notify_pagerduty_acknowledge(alert, alert_id)
else
:ok
end
@@ -95,14 +81,7 @@ defmodule Towerops.Workers.AlertNotificationWorker do
if routing in ["builtin", "both"], do: maybe_resolve_incident(alert)
if routing in ["pagerduty", "both"] do
- case Notifier.notify_resolve(alert) do
- {:error, :not_configured} ->
- Logger.debug("PagerDuty not configured for alert #{alert_id}, skipping")
- :ok
-
- result ->
- result
- end
+ notify_pagerduty_resolve(alert, alert_id)
else
:ok
end
@@ -136,6 +115,39 @@ defmodule Towerops.Workers.AlertNotificationWorker do
|> Oban.insert()
end
+ defp notify_pagerduty_trigger(alert, device, alert_id) do
+ case Notifier.notify_trigger(alert, device) do
+ {:error, :not_configured} ->
+ Logger.debug("PagerDuty not configured for alert #{alert_id}, skipping")
+ :ok
+
+ result ->
+ result
+ end
+ end
+
+ defp notify_pagerduty_acknowledge(alert, alert_id) do
+ case Notifier.notify_acknowledge(alert) do
+ {:error, :not_configured} ->
+ Logger.debug("PagerDuty not configured for alert #{alert_id}, skipping")
+ :ok
+
+ result ->
+ result
+ end
+ end
+
+ defp notify_pagerduty_resolve(alert, alert_id) do
+ case Notifier.notify_resolve(alert) do
+ {:error, :not_configured} ->
+ Logger.debug("PagerDuty not configured for alert #{alert_id}, skipping")
+ :ok
+
+ result ->
+ result
+ end
+ end
+
defp maybe_start_escalation(alert, device) do
policy_id = device.escalation_policy_id || device.organization.default_escalation_policy_id
diff --git a/lib/towerops_web/components/layouts.ex b/lib/towerops_web/components/layouts.ex
index faff2ddc..43f33526 100644
--- a/lib/towerops_web/components/layouts.ex
+++ b/lib/towerops_web/components/layouts.ex
@@ -427,7 +427,7 @@ defmodule ToweropsWeb.Layouts do
-