diff options
Diffstat (limited to 'app/workers/prometheus/create_default_alerts_worker.rb')
-rw-r--r-- | app/workers/prometheus/create_default_alerts_worker.rb | 27 |
1 files changed, 27 insertions, 0 deletions
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 |