diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 18:09:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 18:09:29 +0300 |
commit | 5372e109c0660e4670aa987568a51082beca1b3c (patch) | |
tree | 76f8f1178d5f304f0aea8c0c610729f695c9e18e /app/workers | |
parent | 403678e00406edc8094f087ec70e00aa29e49bef (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/all_queues.yml | 7 | ||||
-rw-r--r-- | app/workers/prometheus/create_default_alerts_worker.rb | 27 |
2 files changed, 34 insertions, 0 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 3ee8901b23b..5e3ea162d20 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -1256,6 +1256,13 @@ :resource_boundary: :unknown :weight: 1 :idempotent: +- :name: prometheus_create_default_alerts + :feature_category: :incident_management + :has_external_dependencies: + :urgency: :high + :resource_boundary: :unknown + :weight: 1 + :idempotent: true - :name: propagate_service_template :feature_category: :source_code_management :has_external_dependencies: diff --git a/app/workers/prometheus/create_default_alerts_worker.rb b/app/workers/prometheus/create_default_alerts_worker.rb new file mode 100644 index 00000000000..2c4fefa9ece --- /dev/null +++ b/app/workers/prometheus/create_default_alerts_worker.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Prometheus + class CreateDefaultAlertsWorker + include ApplicationWorker + + feature_category :incident_management + urgency :high + idempotent! + + def perform(project_id) + project = Project.find_by_id(project_id) + + return unless project + + result = Prometheus::CreateDefaultAlertsService.new(project: project).execute + + log_info(result.message) if result.error? + end + + private + + def log_info(message) + logger.info(structured_payload(message: message)) + end + end +end |