Commit c915f120 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '220415-feature-flag-enable-alert-slack-notifications' into 'master'

Resolve "[Feature flag] Enable Alert Slack notifications"

Closes #220415

See merge request gitlab-org/gitlab!34038
parents f6ea1265 46378bf2
...@@ -156,7 +156,6 @@ module AlertManagement ...@@ -156,7 +156,6 @@ module AlertManagement
end end
def execute_services def execute_services
return unless Feature.enabled?(:alert_slack_event, project)
return unless project.has_active_services?(:alert_hooks) return unless project.has_active_services?(:alert_hooks)
project.execute_services(hook_data, :alert_hooks) project.execute_services(hook_data, :alert_hooks)
......
...@@ -25,7 +25,7 @@ class SlackService < ChatNotificationService ...@@ -25,7 +25,7 @@ class SlackService < ChatNotificationService
def supported_events def supported_events
additional = [] additional = []
additional << 'alert' if Feature.enabled?(:alert_slack_event, project) additional << 'alert'
super + additional super + additional
end end
......
---
title: Enable Slack notifications for alerts
merge_request: 34038
author:
type: added
...@@ -23,7 +23,23 @@ The Slack Notifications Service allows your GitLab project to send events (e.g. ...@@ -23,7 +23,23 @@ The Slack Notifications Service allows your GitLab project to send events (e.g.
Your Slack team will now start receiving GitLab event notifications as configured. Your Slack team will now start receiving GitLab event notifications as configured.
![Slack configuration](img/slack_configuration.png) ### Triggers available for Slack notifications
The following triggers are available for Slack notifications:
- **Push**: Triggered by a push to the repository.
- **Issue**: Triggered when an issue is created, updated, or closed.
- **Confidential issue**: Triggered when a confidential issue is created,
updated, or closed.
- **Merge request**: Triggered when a merge request is created, updated, or
merged.
- **Note**: Triggered when someone adds a comment.
- **Confidential note**: Triggered when someone adds a confidential note.
- **Tag push**: Triggered when a new tag is pushed to the repository.
- **Pipeline**: Triggered when a pipeline status changes.
- **Wiki page**: Triggered when a wiki page is created or updated.
- **Deployment**: Triggered when a deployment finishes.
- **Alert**: Triggered when a new, unique alert is recorded.
## Troubleshooting ## Troubleshooting
......
...@@ -158,3 +158,11 @@ After completing their portion of investigating or fixing the alert, users can ...@@ -158,3 +158,11 @@ After completing their portion of investigating or fixing the alert, users can
unassign their account from the alert when their role is complete. unassign their account from the alert when their role is complete.
The [alerts status](#alert-management-statuses) can be updated to The [alerts status](#alert-management-statuses) can be updated to
reflect if the alert has been resolved. reflect if the alert has been resolved.
### Slack Notifications
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/216326) in GitLab 13.1.
You can be alerted via a Slack message when a new alert has been received.
See the [Slack Notifications Service docs](../integrations/slack.md) for information on how to set this up.
...@@ -90,18 +90,6 @@ RSpec.describe AlertManagement::ProcessPrometheusAlertService do ...@@ -90,18 +90,6 @@ RSpec.describe AlertManagement::ProcessPrometheusAlertService do
expect(ProjectServiceWorker).to have_received(:perform_async).with(slack_service.id, an_instance_of(Hash)) expect(ProjectServiceWorker).to have_received(:perform_async).with(slack_service.id, an_instance_of(Hash))
end end
context 'feature flag disabled' do
before do
stub_feature_flags(alert_slack_event: false)
end
it 'does not execute the alert service hooks' do
subject
expect(ProjectServiceWorker).not_to have_received(:perform_async)
end
end
end end
context 'when alert cannot be created' do context 'when alert cannot be created' do
......
...@@ -145,18 +145,6 @@ describe Projects::Alerting::NotifyService do ...@@ -145,18 +145,6 @@ describe Projects::Alerting::NotifyService do
expect(ProjectServiceWorker).to have_received(:perform_async).with(slack_service.id, an_instance_of(Hash)) expect(ProjectServiceWorker).to have_received(:perform_async).with(slack_service.id, an_instance_of(Hash))
end end
context 'feature flag disabled' do
before do
stub_feature_flags(alert_slack_event: false)
end
it 'does not executes the alert service hooks' do
subject
expect(ProjectServiceWorker).not_to have_received(:perform_async)
end
end
context 'existing alert with same fingerprint' do context 'existing alert with same fingerprint' do
let(:fingerprint_sha) { Digest::SHA1.hexdigest(fingerprint) } let(:fingerprint_sha) { Digest::SHA1.hexdigest(fingerprint) }
let!(:existing_alert) { create(:alert_management_alert, project: project, fingerprint: fingerprint_sha) } let!(:existing_alert) { create(:alert_management_alert, project: project, fingerprint: fingerprint_sha) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment