summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-05-19 18:27:36 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-06-02 19:45:58 +0200
commitc10d55a6dafc6dafe0d3b2d9fad1dc66aee07ff6 (patch)
treef6506a266dd361d7f4d24b0239238e6ad556f9cf
parent6726922890fa0becd6e0bcd91ca5d2fa79fcccef (diff)
downloadgitlab-ce-c10d55a6dafc6dafe0d3b2d9fad1dc66aee07ff6.tar.gz
Use only ENV for metrics folder location
-rw-r--r--app/controllers/metrics_controller.rb8
-rw-r--r--config.ru5
-rw-r--r--config/gitlab.yml.example5
-rw-r--r--config/initializers/1_settings.rb1
-rw-r--r--config/routes.rb8
5 files changed, 12 insertions, 15 deletions
diff --git a/app/controllers/metrics_controller.rb b/app/controllers/metrics_controller.rb
index f283aeb9db0..18c9625c36a 100644
--- a/app/controllers/metrics_controller.rb
+++ b/app/controllers/metrics_controller.rb
@@ -11,9 +11,9 @@ class MetricsController < ActionController::Base
].freeze
def metrics
- render_404 unless Gitlab::Metrics.prometheus_metrics_enabled?
+ return render_404 unless Gitlab::Metrics.prometheus_metrics_enabled?
- metrics_text = Prometheus::Client::Formats::Text.marshal_multiprocess(Settings.gitlab['prometheus_multiproc_dir'])
+ metrics_text = Prometheus::Client::Formats::Text.marshal_multiprocess(multiprocess_metrics_path)
response = health_metrics_text + "\n" + metrics_text
render text: response, content_type: 'text/plain; version=0.0.4'
@@ -21,6 +21,10 @@ class MetricsController < ActionController::Base
private
+ def multiprocess_metrics_path
+ Rails.root.join(ENV['prometheus_multiproc_dir'])
+ end
+
def health_metrics_text
results = CHECKS.flat_map(&:metrics)
diff --git a/config.ru b/config.ru
index cba44122da9..9e474a7c08c 100644
--- a/config.ru
+++ b/config.ru
@@ -13,10 +13,9 @@ if defined?(Unicorn)
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, min, max
end
-
- # TODO(lyda): Needs to be set externally.
- ENV['prometheus_multiproc_dir'] = '/tmp/somestuff'
end
+# set default for multiproces metrics gathering
+ENV['prometheus_multiproc_dir'] ||= 'tmp/prometheus_data_dir'
require ::File.expand_path('../config/environment', __FILE__)
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index a6e4337912b..d2aeb66ebf6 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -102,11 +102,6 @@ production: &base
# The default is 'shared/cache/archive/' relative to the root of the Rails app.
# repository_downloads_path: shared/cache/archive/
- ## Prometheus Client Data directory
- # To be used efficiently in multiprocess Ruby setup like Unicorn, Prometheus client needs to share metrics with other instances.
- # The default is 'tmp/prometheus_data_dir' relative to Rails.root
- # prometheus_multiproc_dir: tmp/prometheus_data_dir
-
## Reply by email
# Allow users to comment on issues and merge requests by replying to notification emails.
# For documentation on how to set this up, see http://doc.gitlab.com/ce/administration/reply_by_email.html
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 5db8746ef4c..45ea2040d23 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -242,7 +242,6 @@ Settings.gitlab['import_sources'] ||= %w[github bitbucket gitlab google_code fog
Settings.gitlab['trusted_proxies'] ||= []
Settings.gitlab['no_todos_messages'] ||= YAML.load_file(Rails.root.join('config', 'no_todos_messages.yml'))
Settings.gitlab['usage_ping_enabled'] = true if Settings.gitlab['usage_ping_enabled'].nil?
-Settings.gitlab['prometheus_multiproc_dir'] ||= ENV['prometheus_multiproc_dir'] || 'tmp/prometheus_data_dir'
#
# CI
diff --git a/config/routes.rb b/config/routes.rb
index 846054e6917..4051c33d5d4 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -38,10 +38,10 @@ Rails.application.routes.draw do
# Health check
get 'health_check(/:checks)' => 'health_check#index', as: :health_check
- scope path: '-', controller: 'health' do
- get :liveness
- get :readiness
- get :metrics
+ scope path: '-' do
+ get 'liveness' => 'health#liveness'
+ get 'readiness' => 'health#readiness'
+ get 'metrics' => 'metrics#metrics'
end
# Koding route