summaryrefslogtreecommitdiff
path: root/lib/gitlab/alert_management/payload/generic.rb
blob: 15238b5e50f7c5a1c7861b0c3ade2bf25f934290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

# Attribute mapping for alerts via generic alerting integration.
module Gitlab
  module AlertManagement
    module Payload
      class Generic < Base
        DEFAULT_TITLE = 'New: Alert'

        attribute :description, paths: 'description'
        attribute :ends_at, paths: 'end_time', type: :time
        attribute :environment_name, paths: 'gitlab_environment_name'
        attribute :hosts, paths: 'hosts'
        attribute :monitoring_tool, paths: 'monitoring_tool'
        attribute :runbook, paths: 'runbook'
        attribute :service, paths: 'service'
        attribute :starts_at, paths: 'start_time', type: :time, fallback: -> { Time.current.utc }
        attribute :title, paths: 'title', fallback: -> { DEFAULT_TITLE }

        attribute :severity_raw, paths: 'severity'
        private :severity_raw

        attribute :plain_gitlab_fingerprint, paths: 'fingerprint'
        private :plain_gitlab_fingerprint
      end
    end
  end
end

Gitlab::AlertManagement::Payload::Generic.prepend_mod_with('Gitlab::AlertManagement::Payload::Generic')