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',
  cilium: 'Cilium'
}.freeze

Class Method Summary collapse

Class Method Details

.parse(project, payload, monitoring_tool: nil, integration: 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:


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

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

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