Class: Gitlab::Prometheus::Internal

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/prometheus/internal.rb

Class Method Summary collapse

Class Method Details

.prometheus_enabled?Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
# File 'lib/gitlab/prometheus/internal.rb', line 36

def self.prometheus_enabled?
  Gitlab.config.prometheus.enabled if Gitlab.config.prometheus
rescue GitlabSettings::MissingSetting
  Gitlab::AppLogger.error('prometheus.enabled is not present in config/gitlab.yml')

  false
end

.server_addressObject



28
29
30
31
32
33
34
# File 'lib/gitlab/prometheus/internal.rb', line 28

def self.server_address
  Gitlab.config.prometheus.server_address.to_s if Gitlab.config.prometheus
rescue GitlabSettings::MissingSetting
  Gitlab::AppLogger.error('Prometheus server_address is not present in config/gitlab.yml')

  nil
end

.uriObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/prometheus/internal.rb', line 6

def self.uri
  return if server_address.blank?

  if server_address.starts_with?('0.0.0.0:')
    # 0.0.0.0:9090
    port = ':' + server_address.split(':').second
    'http://localhost' + port

  elsif server_address.starts_with?(':')
    # :9090
    'http://localhost' + server_address

  elsif server_address.starts_with?('http')
    # https://localhost:9090
    server_address

  else
    # localhost:9090
    'http://' + server_address
  end
end