Add alertmanager integration for heartbeat support (#2807)

Related to https://github.com/grafana/oncall/issues/2801 and
https://github.com/grafana/support-escalations/issues/7081.

---------

Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
This commit is contained in:
Matias Bordese 2023-08-17 10:22:37 -03:00 committed by GitHub
parent 22686669c9
commit 179a1db471
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 3 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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,
},
}