Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-04 12:06:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-04 12:06:21 +0300
commit2b7a5214342baa2575b35868316ea9413d2afe1f (patch)
treef80a862f7fa382620b8f8a695d07b6d1734fc5f5 /lib/gitlab/prometheus
parent15a2d004be2f79160752d77f701c0f08e7f96973 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/prometheus')
-rw-r--r--lib/gitlab/prometheus/internal.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/gitlab/prometheus/internal.rb b/lib/gitlab/prometheus/internal.rb
new file mode 100644
index 00000000000..d59352119ba
--- /dev/null
+++ b/lib/gitlab/prometheus/internal.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Prometheus
+ class Internal
+ def self.uri
+ return if listen_address.blank?
+
+ if listen_address.starts_with?('0.0.0.0:')
+ # 0.0.0.0:9090
+ port = ':' + listen_address.split(':').second
+ 'http://localhost' + port
+
+ elsif listen_address.starts_with?(':')
+ # :9090
+ 'http://localhost' + listen_address
+
+ elsif listen_address.starts_with?('http')
+ # https://localhost:9090
+ listen_address
+
+ else
+ # localhost:9090
+ 'http://' + listen_address
+ end
+ end
+
+ def self.listen_address
+ Gitlab.config.prometheus.listen_address.to_s if Gitlab.config.prometheus
+ rescue Settingslogic::MissingSetting
+ Gitlab::AppLogger.error('Prometheus listen_address is not present in config/gitlab.yml')
+
+ nil
+ end
+
+ def self.prometheus_enabled?
+ Gitlab.config.prometheus.enable if Gitlab.config.prometheus
+ rescue Settingslogic::MissingSetting
+ Gitlab::AppLogger.error('prometheus.enable is not present in config/gitlab.yml')
+
+ false
+ end
+ end
+ end
+end