diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-11-07 00:17:24 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-11-07 00:17:24 +0300 |
commit | 4da03e9977ea3fa5bb422ab0f23f0a60406c7073 (patch) | |
tree | 4e05b131ae65a6083dc77f74a978f95ba51150d7 /config | |
parent | c3d15fa620f218c03dea7100a9e72e18458e4ef3 (diff) | |
parent | 5a085dc12670e6ececa566fc16172da08bac0972 (diff) |
Merge branch 'pawel/metrics-to-prometheus-33643' into 'master'
Add all InfluxDB metrics to prometheus
See merge request gitlab-org/gitlab-ce!13891
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/1_settings.rb | 1 | ||||
-rw-r--r-- | config/initializers/7_prometheus_metrics.rb | 18 | ||||
-rw-r--r-- | config/initializers/8_metrics.rb | 6 |
3 files changed, 19 insertions, 6 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 12694f8016f..d1156b0c8a8 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -535,6 +535,7 @@ Settings.webpack.dev_server['port'] ||= 3808 Settings['monitoring'] ||= Settingslogic.new({}) Settings.monitoring['ip_whitelist'] ||= ['127.0.0.1/8'] Settings.monitoring['unicorn_sampler_interval'] ||= 10 +Settings.monitoring['ruby_sampler_interval'] ||= 60 Settings.monitoring['sidekiq_exporter'] ||= Settingslogic.new({}) Settings.monitoring.sidekiq_exporter['enabled'] ||= false Settings.monitoring.sidekiq_exporter['address'] ||= 'localhost' diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index 31839297523..e8f33593fe0 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -11,7 +11,15 @@ Prometheus::Client.configure do |config| config.multiprocess_files_dir ||= Rails.root.join('tmp/prometheus_multiproc_dir') end - config.pid_provider = Prometheus::Client::Support::Unicorn.method(:worker_pid_provider) + config.pid_provider = -> do + wid = Prometheus::Client::Support::Unicorn.worker_id + wid = Process.pid if wid.nil? + if wid.nil? + "process_pid_#{Process.pid}" + else + "worker_id_#{wid}" + end + end end Sidekiq.configure_server do |config| @@ -19,3 +27,11 @@ Sidekiq.configure_server do |config| Gitlab::Metrics::SidekiqMetricsExporter.instance.start end end + +if Gitlab::Metrics.prometheus_metrics_enabled? + unless Sidekiq.server? + Gitlab::Metrics::Samplers::UnicornSampler.initialize_instance(Settings.monitoring.unicorn_sampler_interval).start + end + + Gitlab::Metrics::Samplers::RubySampler.initialize_instance(Settings.monitoring.ruby_sampler_interval).start +end diff --git a/config/initializers/8_metrics.rb b/config/initializers/8_metrics.rb index 9c53a33d245..7ef594836d6 100644 --- a/config/initializers/8_metrics.rb +++ b/config/initializers/8_metrics.rb @@ -118,10 +118,6 @@ def instrument_classes(instrumentation) end # rubocop:enable Metrics/AbcSize -unless Sidekiq.server? - Gitlab::Metrics::UnicornSampler.initialize_instance(Settings.monitoring.unicorn_sampler_interval).start -end - Gitlab::Application.configure do |config| # 0 should be Sentry to catch errors in this middleware config.middleware.insert(1, Gitlab::Metrics::RequestsRackMiddleware) @@ -187,7 +183,7 @@ if Gitlab::Metrics.enabled? GC::Profiler.enable - Gitlab::Metrics::InfluxSampler.initialize_instance.start + Gitlab::Metrics::Samplers::InfluxSampler.initialize_instance.start module TrackNewRedisConnections def connect(*args) |