summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-08 15:09:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-08 15:09:24 +0000
commit833d57e60da633435d845a7867e46e6092c46520 (patch)
tree35676d3a0da36ef28b67cadb06af474b6c8f5b85 /app/services
parentc52b72f5772d52e9fc85bd9f4e8b8497a6278c37 (diff)
downloadgitlab-ce-833d57e60da633435d845a7867e46e6092c46520.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/projects/prometheus/alerts/create_events_service.rb71
-rw-r--r--app/services/projects/prometheus/alerts/notify_service.rb13
2 files changed, 0 insertions, 84 deletions
diff --git a/app/services/projects/prometheus/alerts/create_events_service.rb b/app/services/projects/prometheus/alerts/create_events_service.rb
deleted file mode 100644
index 4fcf841314b..00000000000
--- a/app/services/projects/prometheus/alerts/create_events_service.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-# frozen_string_literal: true
-
-module Projects
- module Prometheus
- module Alerts
- # Persists a series of Prometheus alert events as list of PrometheusAlertEvent.
- class CreateEventsService < BaseService
- def execute
- create_events_from(alerts)
- end
-
- private
-
- def create_events_from(alerts)
- Array.wrap(alerts).map { |alert| create_event(alert) }.compact
- end
-
- def create_event(payload)
- parsed_alert = Gitlab::Alerting::Alert.new(project: project, payload: payload)
-
- return unless parsed_alert.valid?
-
- if parsed_alert.gitlab_managed?
- create_managed_prometheus_alert_event(parsed_alert)
- else
- create_self_managed_prometheus_alert_event(parsed_alert)
- end
- end
-
- def alerts
- params['alerts']
- end
-
- def find_alert(metric)
- Projects::Prometheus::AlertsFinder
- .new(project: project, metric: metric)
- .execute
- .first
- end
-
- def create_managed_prometheus_alert_event(parsed_alert)
- alert = find_alert(parsed_alert.metric_id)
- event = PrometheusAlertEvent.find_or_initialize_by_payload_key(parsed_alert.project, alert, parsed_alert.gitlab_fingerprint)
-
- set_status(parsed_alert, event)
- end
-
- def create_self_managed_prometheus_alert_event(parsed_alert)
- event = SelfManagedPrometheusAlertEvent.find_or_initialize_by_payload_key(parsed_alert.project, parsed_alert.gitlab_fingerprint) do |event|
- event.environment = parsed_alert.environment
- event.title = parsed_alert.title
- event.query_expression = parsed_alert.full_query
- end
-
- set_status(parsed_alert, event)
- end
-
- def set_status(parsed_alert, event)
- persisted = case parsed_alert.status
- when 'firing'
- event.fire(parsed_alert.starts_at)
- when 'resolved'
- event.resolve(parsed_alert.ends_at)
- end
-
- event if persisted
- end
- end
- end
- end
-end
diff --git a/app/services/projects/prometheus/alerts/notify_service.rb b/app/services/projects/prometheus/alerts/notify_service.rb
index 877a4f99a94..4b3aed2d1d9 100644
--- a/app/services/projects/prometheus/alerts/notify_service.rb
+++ b/app/services/projects/prometheus/alerts/notify_service.rb
@@ -23,9 +23,7 @@ module Projects
return unauthorized unless valid_alert_manager_token?(token)
process_prometheus_alerts
- persist_events
send_alert_email if send_email?
- process_incident_issues if process_issues?
ServiceResponse.success
end
@@ -132,13 +130,6 @@ module Projects
.prometheus_alerts_fired(project, firings)
end
- def process_incident_issues
- alerts.each do |alert|
- IncidentManagement::ProcessPrometheusAlertWorker
- .perform_async(project.id, alert.to_h)
- end
- end
-
def process_prometheus_alerts
alerts.each do |alert|
AlertManagement::ProcessPrometheusAlertService
@@ -147,10 +138,6 @@ module Projects
end
end
- def persist_events
- CreateEventsService.new(project, nil, params).execute
- end
-
def bad_request
ServiceResponse.error(message: 'Bad Request', http_status: :bad_request)
end