-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AlertManager v2 #2643
Merged
Merged
AlertManager v2 #2643
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
4d5fa44
First pass on AlertManager v2
Konstantinov-Innokentii 1a24597
Introduce legacy_prefix package
Konstantinov-Innokentii a3d41fe
Merge branch 'dev' into grafana_alerting_v2
Konstantinov-Innokentii bd731f9
Use set literal for INTEGRATION_TYPES
Konstantinov-Innokentii 7d9c9e7
Add migrate endpoint for integration
Konstantinov-Innokentii 1422bd1
Temporary allow creating legacy integrations
Konstantinov-Innokentii 1f685ef
Merge branch 'dev' into amv2
Konstantinov-Innokentii 22f79e6
Update CHANGELOG.md
Konstantinov-Innokentii 802dd63
Merge remote-tracking branch 'origin/amv2' into amv2
Konstantinov-Innokentii cb18375
Decouple GrafanaAPIView from AlertManagerAPIView
Konstantinov-Innokentii 342cfaf
based_on_alertmanager naming
Konstantinov-Innokentii 06b865a
Hack to keep demo alert working for integration with legacy AM behaviour
Konstantinov-Innokentii fe903b7
Add migration
Konstantinov-Innokentii 2c4084c
frontend changes
teodosii 629f46c
fixed updateItems by passing the page param
teodosii 13b6a83
isLegacy check
teodosii 4d29d48
Draft docs
Konstantinov-Innokentii 0234c71
Docs iteration
Konstantinov-Innokentii 58d7f59
Docs polishing
Konstantinov-Innokentii 2c7940a
Docs polishing
Konstantinov-Innokentii f200d95
Add annotations to payload example
Konstantinov-Innokentii f5cdbf5
Merge branch 'dev' into amv2
Konstantinov-Innokentii cbe4328
Text polishing
Konstantinov-Innokentii 052ae46
Fix typos
Konstantinov-Innokentii 046636a
Merge remote-tracking branch 'origin/dev' into amv2
Konstantinov-Innokentii a67f92f
Temporary remove migration
Konstantinov-Innokentii 78ed3ef
Fix Changelog
Konstantinov-Innokentii 05e4ee8
frontend changes
teodosii d6d91e6
linter
teodosii fef74ea
ui display changes
teodosii 6e7253d
Polishing
Konstantinov-Innokentii 166cf97
Merge branch 'dev' into amv2
Konstantinov-Innokentii dc468c1
Fix tests
Konstantinov-Innokentii 54cbfa6
Comments polishing
Konstantinov-Innokentii c17dd28
Add migration
Konstantinov-Innokentii d9b70d8
Docs polishing
Konstantinov-Innokentii 38e20c3
Comment polishing
Konstantinov-Innokentii 16da5c1
Refresh templates on migration
Konstantinov-Innokentii 283282d
Merge branch 'dev' into amv2
joeyorlando f4630bc
Update docs/sources/integrations/alertmanager/index.md
Konstantinov-Innokentii 029abef
Merge branch 'dev' into amv2
Konstantinov-Innokentii 58ffe1b
Rename migrateChannelFiter to migrateChannel
Konstantinov-Innokentii a228f83
Remove excess function
Konstantinov-Innokentii c08937c
Skip test_related_shifts
Konstantinov-Innokentii 5fe2dbb
Fix migration
Konstantinov-Innokentii a5c05ad
Polishing
Konstantinov-Innokentii b6bc830
Add migration Date on frontend
Konstantinov-Innokentii 237cce1
Fix tests
Konstantinov-Innokentii 4a01a81
Skip test_related_shifts
Konstantinov-Innokentii 595e7ac
Update CHANGELOG.md
Konstantinov-Innokentii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Generated by Django 3.2.19 on 2023-07-31 03:41 | ||
|
||
from django.db import migrations | ||
|
||
|
||
integration_alertmanager = "alertmanager" | ||
integration_grafana_alerting = "grafana_alerting" | ||
|
||
legacy_alertmanager = "legacy_alertmanager" | ||
legacy_grafana_alerting = "legacy_grafana_alerting" | ||
|
||
|
||
def make_integrations_legacy(apps, schema_editor): | ||
AlertReceiveChannel = apps.get_model("alerts", "AlertReceiveChannel") | ||
|
||
|
||
AlertReceiveChannel.objects.filter(integration=integration_alertmanager).update(integration=legacy_alertmanager) | ||
AlertReceiveChannel.objects.filter(integration=integration_grafana_alerting).update(integration=legacy_grafana_alerting) | ||
|
||
|
||
def revert_make_integrations_legacy(apps, schema_editor): | ||
AlertReceiveChannel = apps.get_model("alerts", "AlertReceiveChannel") | ||
|
||
|
||
AlertReceiveChannel.objects.filter(integration=legacy_alertmanager).update(integration=integration_alertmanager) | ||
AlertReceiveChannel.objects.filter(integration=legacy_grafana_alerting).update(integration=integration_grafana_alerting) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('alerts', '0029_auto_20230728_0802'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(make_integrations_legacy, revert_make_integrations_legacy), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from apps.alerts.models import AlertReceiveChannel | ||
from apps.alerts.models.channel_filter import ChannelFilter | ||
from apps.base.messaging import get_messaging_backends | ||
from apps.integrations.legacy_prefix import has_legacy_prefix | ||
from common.api_helpers.custom_fields import TeamPrimaryKeyRelatedField | ||
from common.api_helpers.exceptions import BadRequest | ||
from common.api_helpers.mixins import APPEARANCE_TEMPLATE_NAMES, EagerLoadingMixin | ||
|
@@ -52,6 +53,7 @@ class AlertReceiveChannelSerializer(EagerLoadingMixin, serializers.ModelSerializ | |
routes_count = serializers.SerializerMethodField() | ||
connected_escalations_chains_count = serializers.SerializerMethodField() | ||
inbound_email = serializers.CharField(required=False) | ||
is_legacy = serializers.SerializerMethodField() | ||
|
||
# integration heartbeat is in PREFETCH_RELATED not by mistake. | ||
# With using of select_related ORM builds strange join | ||
|
@@ -90,6 +92,7 @@ class Meta: | |
"connected_escalations_chains_count", | ||
"is_based_on_alertmanager", | ||
"inbound_email", | ||
"is_legacy", | ||
] | ||
read_only_fields = [ | ||
"created_at", | ||
|
@@ -105,12 +108,15 @@ class Meta: | |
"connected_escalations_chains_count", | ||
"is_based_on_alertmanager", | ||
"inbound_email", | ||
"is_legacy", | ||
] | ||
extra_kwargs = {"integration": {"required": True}} | ||
|
||
def create(self, validated_data): | ||
organization = self.context["request"].auth.organization | ||
integration = validated_data.get("integration") | ||
# if has_legacy_prefix(integration): | ||
# raise BadRequest(detail="This integration is deprecated") | ||
Comment on lines
+118
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be uncommented or removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bumping this |
||
if integration == AlertReceiveChannel.INTEGRATION_GRAFANA_ALERTING: | ||
connection_error = GrafanaAlertingSyncManager.check_for_connection_errors(organization) | ||
if connection_error: | ||
|
@@ -185,6 +191,9 @@ def get_alert_groups_count(self, obj): | |
def get_routes_count(self, obj) -> int: | ||
return obj.channel_filters.count() | ||
|
||
def get_is_legacy(self, obj) -> bool: | ||
return has_legacy_prefix(obj.integration) | ||
|
||
def get_connected_escalations_chains_count(self, obj) -> int: | ||
return ( | ||
ChannelFilter.objects.filter(alert_receive_channel=obj, escalation_chain__isnull=False) | ||
|
@@ -262,7 +271,7 @@ def get_payload_example(self, obj): | |
return None | ||
|
||
def get_is_based_on_alertmanager(self, obj): | ||
return obj.has_alertmanager_payload_structure | ||
return obj.based_on_alertmanager | ||
|
||
# Override method to pass field_name directly in set_value to handle None values for WritableSerializerField | ||
def to_internal_value(self, data): | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide more clear instruction what should be done here and when?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I can't. We still have GRAFANA integration which might or might not have legacy alertmanager behaviour and that's why there is no clear instruction what to do. I'll remove TODO.