diff --git a/CHANGELOG.md b/CHANGELOG.md index b87074ac..4487584d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix issue with updating "Require resolution note" setting by @Ferril ([#2782](https://github.com/grafana/oncall/pull/2782)) - Don't send notifications about past SSRs when turning on info notifications by @vadimkerr ([#2783](https://github.com/grafana/oncall/pull/2783)) - Add schedule shift type validation on create/preview ([#2789](https://github.com/grafana/oncall/pull/2789)) +- Add alertmanager integration for heartbeat support ([2807](https://github.com/grafana/oncall/pull/2807)) ## v1.3.23 (2023-08-10) diff --git a/engine/apps/alerts/tests/test_alert_receiver_channel.py b/engine/apps/alerts/tests/test_alert_receiver_channel.py index ab94e6a4..a4628cb7 100644 --- a/engine/apps/alerts/tests/test_alert_receiver_channel.py +++ b/engine/apps/alerts/tests/test_alert_receiver_channel.py @@ -206,3 +206,17 @@ def test_get_or_create_manual_integration_deleted_team(make_organization, make_t organization=organization, team=None, integration=AlertReceiveChannel.INTEGRATION_MANUAL, defaults={} ) assert integration == general_manual + + +@pytest.mark.django_db +@pytest.mark.parametrize( + "integration", + [ + AlertReceiveChannel.INTEGRATION_LEGACY_ALERTMANAGER, + AlertReceiveChannel.INTEGRATION_ALERTMANAGER, + ], +) +def test_alertmanager_available_for_heartbeat(make_organization, make_alert_receive_channel, integration): + organization = make_organization() + alert_receive_channel = make_alert_receive_channel(organization, integration=integration) + assert alert_receive_channel.is_available_for_integration_heartbeat diff --git a/engine/apps/integrations/metadata/heartbeat/__init__.py b/engine/apps/integrations/metadata/heartbeat/__init__.py index 1c987dc0..464f11d6 100644 --- a/engine/apps/integrations/metadata/heartbeat/__init__.py +++ b/engine/apps/integrations/metadata/heartbeat/__init__.py @@ -4,6 +4,7 @@ Files from this modules are integrations for which heartbeat is available (if fi Filename MUST match INTEGRATION_TO_REVERSE_URL_MAP. """ +import apps.integrations.metadata.heartbeat.alertmanager # noqa import apps.integrations.metadata.heartbeat.elastalert # noqa import apps.integrations.metadata.heartbeat.formatted_webhook # noqa import apps.integrations.metadata.heartbeat.grafana # noqa diff --git a/engine/apps/integrations/metadata/heartbeat/alertmanager.py b/engine/apps/integrations/metadata/heartbeat/alertmanager.py index 7077efc3..ea7a2648 100644 --- a/engine/apps/integrations/metadata/heartbeat/alertmanager.py +++ b/engine/apps/integrations/metadata/heartbeat/alertmanager.py @@ -37,7 +37,10 @@ heartbeat_expired_payload = { "numResolved": 0, "commonLabels": {"alertname": "OnCallHeartBeatMissing"}, "truncatedAlerts": 0, - "commonAnnotations": {}, + "commonAnnotations": { + "title": heartbeat_expired_title, + "description": heartbeat_expired_message, + }, } heartbeat_restored_title = heartbeat_text.heartbeat_restored_title @@ -61,7 +64,7 @@ heartbeat_restored_payload = { "generatorURL": "", }, ], - "status": "firing", + "status": "resolved", "version": "4", "groupKey": '{}:{alertname="OnCallHeartBeatMissing"}', "receiver": "", @@ -71,5 +74,8 @@ heartbeat_restored_payload = { "numResolved": 1, "commonLabels": {"alertname": "OnCallHeartBeatMissing"}, "truncatedAlerts": 0, - "commonAnnotations": {}, + "commonAnnotations": { + "title": heartbeat_restored_title, + "description": heartbeat_restored_message, + }, }