Skip to content

Commit

Permalink
Add alertmanager integration for heartbeat support (#2807)
Browse files Browse the repository at this point in the history
Related to #2801 and
grafana/support-escalations#7081.

---------

Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
  • Loading branch information
matiasb and Konstantinov-Innokentii authored Aug 17, 2023
1 parent 2268666 commit 179a1db
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions engine/apps/alerts/tests/test_alert_receiver_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions engine/apps/integrations/metadata/heartbeat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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
Expand Down
12 changes: 9 additions & 3 deletions engine/apps/integrations/metadata/heartbeat/alertmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
"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
Expand All @@ -61,7 +64,7 @@
"generatorURL": "",
},
],
"status": "firing",
"status": "resolved",
"version": "4",
"groupKey": '{}:{alertname="OnCallHeartBeatMissing"}',
"receiver": "",
Expand All @@ -71,5 +74,8 @@
"numResolved": 1,
"commonLabels": {"alertname": "OnCallHeartBeatMissing"},
"truncatedAlerts": 0,
"commonAnnotations": {},
"commonAnnotations": {
"title": heartbeat_restored_title,
"description": heartbeat_restored_message,
},
}

0 comments on commit 179a1db

Please sign in to comment.