Class: Gitlab::Metrics::Dashboard::Url

Inherits:
Object
  • Object
show all
Extended by:
Utils::StrongMemoize
Defined in:
lib/gitlab/metrics/dashboard/url.rb

Constant Summary collapse

QUERY_PATTERN =
'(?<query>\?[a-zA-Z0-9%.()+_=-]+(&[a-zA-Z0-9%.()+_=-]+)*)?'
ANCHOR_PATTERN =
'(?<anchor>\#[a-z0-9_-]+)?'
DASH_PATTERN =
'(?:/-)'

Class Method Summary collapse

Methods included from Utils::StrongMemoize

clear_memoization, strong_memoize, strong_memoized?

Class Method Details

.alert_regexObject

Matches dashboard urls for a metric chart embed for a specifc firing GitLab alert

EX -


76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/gitlab/metrics/dashboard/url.rb', line 76

def alert_regex
  strong_memoize(:alert_regex) do
    regex_for_project_metrics(
      %r{
        #{DASH_PATTERN}?
        /prometheus
        /alerts
        /(?<alert>\d+)
        /metrics_dashboard(\.json)?
      }x
    )
  end
end

.build_dashboard_url(*args) ⇒ Object

Builds a metrics dashboard url based on the passed in arguments


103
104
105
# File 'lib/gitlab/metrics/dashboard/url.rb', line 103

def build_dashboard_url(*args)
  Gitlab::Routing.url_helpers.metrics_dashboard_namespace_project_environment_url(*args)
end

.grafana_regexObject

Matches dashboard urls for a Grafana embed.

EX -


38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gitlab/metrics/dashboard/url.rb', line 38

def grafana_regex
  strong_memoize(:grafana_regex) do
    regex_for_project_metrics(
      %r{
        #{DASH_PATTERN}?
        /grafana
        /metrics_dashboard
      }x
    )
  end
end