Module: Gitlab::AlertManagement::Payload

Defined in:
lib/gitlab/alert_management/payload.rb,
lib/gitlab/alert_management/payload/base.rb,
lib/gitlab/alert_management/payload/generic.rb,
lib/gitlab/alert_management/payload/prometheus.rb,
lib/gitlab/alert_management/payload/managed_prometheus.rb

Defined Under Namespace

Classes: Base, Generic, ManagedPrometheus, Prometheus

Constant Summary collapse

MONITORING_TOOLS =
{
  prometheus: 'Prometheus'
}.freeze

Class Method Summary collapse

Class Method Details

.parse(project, payload, monitoring_tool: nil) ⇒ Object

Instantiates an instance of a subclass of Gitlab::AlertManagement::Payload::Base. This can be used to create new alerts or read content from the payload of an existing AlertManagement::Alert

Parameters:

  • project (Project)
  • payload (Hash)
  • monitoring_tool (String) (defaults to: nil)

19
20
21
22
23
24
25
26
# File 'lib/gitlab/alert_management/payload.rb', line 19

def parse(project, payload, monitoring_tool: nil)
  payload_class = payload_class_for(
    monitoring_tool: monitoring_tool || payload&.dig('monitoring_tool'),
    payload: payload
  )

  payload_class.new(project: project, payload: payload)
end