diff options
Diffstat (limited to 'lib/gitlab/prometheus')
-rw-r--r-- | lib/gitlab/prometheus/internal.rb | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/gitlab/prometheus/internal.rb b/lib/gitlab/prometheus/internal.rb index c2f4035821e..fe06b97add6 100644 --- a/lib/gitlab/prometheus/internal.rb +++ b/lib/gitlab/prometheus/internal.rb @@ -4,43 +4,39 @@ module Gitlab module Prometheus class Internal def self.uri - return if listen_address.blank? + return if server_address.blank? - if listen_address.starts_with?('0.0.0.0:') + if server_address.starts_with?('0.0.0.0:') # 0.0.0.0:9090 - port = ':' + listen_address.split(':').second + port = ':' + server_address.split(':').second 'http://localhost' + port - elsif listen_address.starts_with?(':') + elsif server_address.starts_with?(':') # :9090 - 'http://localhost' + listen_address + 'http://localhost' + server_address - elsif listen_address.starts_with?('http') + elsif server_address.starts_with?('http') # https://localhost:9090 - listen_address + server_address else # localhost:9090 - 'http://' + listen_address + 'http://' + server_address end end def self.server_address - uri&.strip&.sub(/^http[s]?:\/\//, '') - end - - def self.listen_address - Gitlab.config.prometheus.listen_address.to_s if Gitlab.config.prometheus + Gitlab.config.prometheus.server_address.to_s if Gitlab.config.prometheus rescue Settingslogic::MissingSetting - Gitlab::AppLogger.error('Prometheus listen_address is not present in config/gitlab.yml') + Gitlab::AppLogger.error('Prometheus server_address is not present in config/gitlab.yml') nil end def self.prometheus_enabled? - Gitlab.config.prometheus.enable if Gitlab.config.prometheus + Gitlab.config.prometheus.enabled if Gitlab.config.prometheus rescue Settingslogic::MissingSetting - Gitlab::AppLogger.error('prometheus.enable is not present in config/gitlab.yml') + Gitlab::AppLogger.error('prometheus.enabled is not present in config/gitlab.yml') false end |