Class: Gitlab::AlertManagement::Payload::Prometheus

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/alert_management/payload/prometheus.rb

Direct Known Subclasses

ManagedPrometheus

Constant Summary collapse

METRIC_TIME_WINDOW =
30.minutes

Constants inherited from Base

Base::EXPECTED_PAYLOAD_ATTRIBUTES

Instance Attribute Summary

Attributes inherited from Base

#payload, #project

Instance Method Summary collapse

Methods inherited from Base

#alert_params, attribute, #environment, #gitlab_fingerprint, #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

#full_queryObject

Parses `g0.expr` from `generatorURL`.

Example: localhost:9090/graph?g0.expr=vector%281%29&g0.tab=1


43
44
45
46
47
48
49
50
# File 'lib/gitlab/alert_management/payload/prometheus.rb', line 43

def full_query
  return unless generator_url

  uri = URI(generator_url)

  Rack::Utils.parse_query(uri.query).fetch('g0.expr')
rescue URI::InvalidURIError, KeyError
end

#has_required_attributes?Boolean

Returns:

  • (Boolean)

64
65
66
# File 'lib/gitlab/alert_management/payload/prometheus.rb', line 64

def has_required_attributes?
  project && title && starts_at_raw
end

#metrics_dashboard_urlObject


52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gitlab/alert_management/payload/prometheus.rb', line 52

def metrics_dashboard_url
  return unless environment && full_query && title

  metrics_dashboard_project_environment_url(
    project,
    environment,
    embed_json: dashboard_json,
    embedded: true,
    **alert_embed_window_params
  )
end

#monitoring_toolObject


36
37
38
# File 'lib/gitlab/alert_management/payload/prometheus.rb', line 36

def monitoring_tool
  Gitlab::AlertManagement::Payload::MONITORING_TOOLS[:prometheus]
end