Class: Gitlab::AlertManagement::Payload::ManagedPrometheus

Inherits:
Prometheus
  • Object
show all
Defined in:
lib/gitlab/alert_management/payload/managed_prometheus.rb

Constant Summary

Constants inherited from Prometheus

Prometheus::METRIC_TIME_WINDOW

Constants inherited from Base

Base::EXPECTED_PAYLOAD_ATTRIBUTES

Instance Attribute Summary

Attributes inherited from Base

#payload, #project

Instance Method Summary collapse

Methods inherited from Prometheus

#has_required_attributes?, #monitoring_tool

Methods inherited from Base

#alert_params, attribute, #gitlab_fingerprint, #has_required_attributes?, #resolved?

Methods included from Routing

add_helpers, includes_helpers, redirect_legacy_paths, url_helpers

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#environmentObject


34
35
36
# File 'lib/gitlab/alert_management/payload/managed_prometheus.rb', line 34

def environment
  gitlab_alert&.environment || super
end

#full_queryObject


30
31
32
# File 'lib/gitlab/alert_management/payload/managed_prometheus.rb', line 30

def full_query
  gitlab_alert&.full_query || super
end

#gitlab_alertObject


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/alert_management/payload/managed_prometheus.rb', line 16

def gitlab_alert
  strong_memoize(:gitlab_alert) do
    next unless metric_id || gitlab_prometheus_alert_id

    alerts = Projects::Prometheus::AlertsFinder
      .new(project: project, metric: metric_id, id: gitlab_prometheus_alert_id)
      .execute

    next if alerts.blank? || alerts.size > 1

    alerts.first
  end
end

#metrics_dashboard_urlObject


38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gitlab/alert_management/payload/managed_prometheus.rb', line 38

def metrics_dashboard_url
  return unless gitlab_alert

  metrics_dashboard_project_prometheus_alert_url(
    project,
    gitlab_alert.prometheus_metric_id,
    environment_id: environment.id,
    embedded: true,
    **alert_embed_window_params
  )
end