Commit 875a6d3b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-disable-sidekiq-exporter-logs' into 'master'

Disable Sidekiq Exporter logs by default

See merge request gitlab-org/gitlab!42267
parents 2ff3c889 2f98ee29
---
title: Disable Sidekiq Exporter logs by default
merge_request: 42267
author:
type: changed
......@@ -1136,6 +1136,7 @@ production: &base
# Sidekiq exporter is webserver built in to Sidekiq to expose Prometheus metrics
sidekiq_exporter:
# enabled: true
# log_enabled: false
# address: localhost
# port: 8082
......
......@@ -784,6 +784,7 @@ Settings.monitoring['ip_whitelist'] ||= ['127.0.0.1/8']
Settings.monitoring['unicorn_sampler_interval'] ||= 10
Settings.monitoring['sidekiq_exporter'] ||= Settingslogic.new({})
Settings.monitoring.sidekiq_exporter['enabled'] ||= false
Settings.monitoring.sidekiq_exporter['log_enabled'] ||= false
Settings.monitoring.sidekiq_exporter['address'] ||= 'localhost'
Settings.monitoring.sidekiq_exporter['port'] ||= 8082
Settings.monitoring['web_exporter'] ||= Settingslogic.new({})
......
......@@ -723,10 +723,15 @@ was initiated, such as `1509705644.log`
## `sidekiq_exporter.log` and `web_exporter.log`
If Prometheus metrics and the Sidekiq Exporter are both enabled, Sidekiq will
start a Web server and listen to the defined port (default: `8082`). Access logs
will be generated in `/var/log/gitlab/gitlab-rails/sidekiq_exporter.log` for
Omnibus GitLab packages or in `/home/git/gitlab/log/sidekiq_exporter.log` for
If Prometheus metrics and the Sidekiq Exporter are both enabled, Sidekiq
will start a Web server and listen to the defined port (default:
`8082`). By default, Sidekiq Exporter access logs are disabled but can
be enabled via the `sidekiq['exporter_log_enabled'] = true` option in `/etc/gitlab/gitlab.rb`
for Omnibus installations, or via the `sidekiq_exporter.log_enabled` option
in `gitlab.yml` for installations from source. When enabled,
access logs will be generated in
`/var/log/gitlab/gitlab-rails/sidekiq_exporter.log` for Omnibus GitLab
packages or in `/home/git/gitlab/log/sidekiq_exporter.log` for
installations from source.
If Prometheus metrics and the Web Exporter are both enabled, Puma/Unicorn will
......
......@@ -12,7 +12,11 @@ module Gitlab
end
def log_filename
File.join(Rails.root, 'log', 'sidekiq_exporter.log')
if settings['log_enabled']
File.join(Rails.root, 'log', 'sidekiq_exporter.log')
else
File::NULL
end
end
private
......
......@@ -15,6 +15,7 @@ RSpec.describe Gitlab::Metrics::Exporter::SidekiqExporter do
monitoring: {
sidekiq_exporter: {
enabled: true,
log_enabled: false,
port: 0,
address: '127.0.0.1'
}
......@@ -25,6 +26,29 @@ RSpec.describe Gitlab::Metrics::Exporter::SidekiqExporter do
it 'does start thread' do
expect(exporter.start).not_to be_nil
end
it 'does not enable logging by default' do
expect(exporter.log_filename).to eq(File::NULL)
end
end
context 'with logging enabled' do
before do
stub_config(
monitoring: {
sidekiq_exporter: {
enabled: true,
log_enabled: true,
port: 0,
address: '127.0.0.1'
}
}
)
end
it 'returns a valid log filename' do
expect(exporter.log_filename).to end_with('sidekiq_exporter.log')
end
end
context 'when port is already taken' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment