2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Attribute mapping for alerts via generic alerting integration.
|
|
|
|
module Gitlab
|
|
|
|
module AlertManagement
|
|
|
|
module Payload
|
|
|
|
class Generic < Base
|
2021-04-17 20:07:23 +05:30
|
|
|
DEFAULT_TITLE = 'New: Alert'
|
2022-10-11 01:57:18 +05:30
|
|
|
DEFAULT_SOURCE = 'Generic Alert Endpoint'
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
attribute :description, paths: 'description'
|
|
|
|
attribute :ends_at, paths: 'end_time', type: :time
|
2020-11-24 15:15:51 +05:30
|
|
|
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 }
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
attribute :severity_raw, paths: 'severity'
|
|
|
|
private :severity_raw
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
attribute :plain_gitlab_fingerprint, paths: 'fingerprint'
|
|
|
|
private :plain_gitlab_fingerprint
|
2022-10-11 01:57:18 +05:30
|
|
|
|
|
|
|
def resolved?
|
|
|
|
ends_at.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def source
|
|
|
|
super || DEFAULT_SOURCE
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
Gitlab::AlertManagement::Payload::Generic.prepend_mod_with('Gitlab::AlertManagement::Payload::Generic')
|