Commit f085ec5f authored by Sean Arnold's avatar Sean Arnold

Create issue automatically from Prometheus alert

parent 1b7292d3
...@@ -34,6 +34,8 @@ module AlertManagement ...@@ -34,6 +34,8 @@ module AlertManagement
else else
create_alert_management_alert create_alert_management_alert
end end
create_incident
end end
def reset_alert_management_alert_status def reset_alert_management_alert_status
...@@ -89,6 +91,14 @@ module AlertManagement ...@@ -89,6 +91,14 @@ module AlertManagement
SystemNoteService.auto_resolve_prometheus_alert(issue, project, User.alert_bot) if issue.reset.closed? SystemNoteService.auto_resolve_prometheus_alert(issue, project, User.alert_bot) if issue.reset.closed?
end end
def create_incident
clear_memoization(:am_alert) if am_alert.blank?
return unless am_alert
return if am_alert.issue
IncidentManagement::ProcessAlertWorker.new.perform(nil, nil, am_alert.id)
end
def logger def logger
@logger ||= Gitlab::AppLogger @logger ||= Gitlab::AppLogger
end end
......
...@@ -30,7 +30,11 @@ module IncidentManagement ...@@ -30,7 +30,11 @@ module IncidentManagement
end end
def parsed_payload(alert) def parsed_payload(alert)
Gitlab::Alerting::NotificationPayloadParser.call(alert.payload.to_h, alert.project) if alert.prometheus?
alert.payload
else
Gitlab::Alerting::NotificationPayloadParser.call(alert.payload.to_h, alert.project)
end
end end
def create_issue_for(alert) def create_issue_for(alert)
......
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