Merge branch 'redis' into 'master'
Add optional redis-exporter to omnibus See merge request !1118
This commit is contained in:
commit
3bd03d2d0b
|
@ -97,6 +97,7 @@ dependency "gitlab-config-template"
|
|||
dependency "mattermost"
|
||||
dependency "node-exporter"
|
||||
dependency "prometheus"
|
||||
dependency "redis-exporter"
|
||||
|
||||
# version manifest file
|
||||
dependency "version-manifest"
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
## Copyright:: Copyright (c) 2014 GitLab.com
|
||||
## License:: Apache License, Version 2.0
|
||||
##
|
||||
## Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
## you may not use this file except in compliance with the License.
|
||||
## You may obtain a copy of the License at
|
||||
##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0
|
||||
##
|
||||
## Unless required by applicable law or agreed to in writing, software
|
||||
## distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
##
|
||||
#
|
||||
|
||||
name 'redis-exporter'
|
||||
default_version 'v0.10.6'
|
||||
|
||||
license 'MIT'
|
||||
license_file 'LICENSE'
|
||||
|
||||
source git: 'https://github.com/oliver006/redis_exporter.git'
|
||||
|
||||
relative_path 'src/github.com/oliver006/redis_exporter'
|
||||
|
||||
build do
|
||||
env = {
|
||||
'GOPATH' => "#{Omnibus::Config.source_dir}/redis-exporter",
|
||||
'GO15VENDOREXPERIMENT' => '1' # Build machines have go 1.5.x, use vendor directory
|
||||
}
|
||||
command 'go install github.com/Masterminds/glide', env: env
|
||||
command '../../../../bin/glide install ', env: env
|
||||
command 'go build', env: env
|
||||
copy 'redis_exporter', "#{install_dir}/embedded/bin/"
|
||||
end
|
|
@ -19,6 +19,7 @@ by default:
|
|||
| Nginx status | Yes | Port | X | 8060 |
|
||||
| Node exporter | No | Port | X | 9100 |
|
||||
| Prometheus | No | Port | X | 9090 |
|
||||
| Redis exporter | No | Port | X | 9121 |
|
||||
| Redis Sentinel | No | Port | X | 26379 |
|
||||
| Incoming email | No | Port | X | 143 |
|
||||
| Elastic search | No | Port | X | 9200 |
|
||||
|
|
|
@ -1181,6 +1181,21 @@ external_url 'GENERATED_EXTERNAL_URL'
|
|||
##! Advanced settings. Should be changed only if absolutely needed.
|
||||
# node_exporter['listen_address'] = 'localhost:9100'
|
||||
|
||||
################################################################################
|
||||
# Prometheus Redis exporter
|
||||
################################################################################
|
||||
|
||||
##! Docs: https://docs.gitlab.com/ce/administration/monitoring/performance/prometheus.html
|
||||
|
||||
#default['gitlab']['redis-exporter']['enable'] = false
|
||||
#default['gitlab']['redis-exporter']['log_directory'] = "/var/log/gitlab/redis-exporter"
|
||||
#default['gitlab']['redis-exporter']['flags'] = {
|
||||
# 'redis.addr' => "unix://#{node['gitlab']['gitlab-rails']['redis_socket']}",
|
||||
#}
|
||||
|
||||
##! Advanced settings. Should be changed only if absolutely needed.
|
||||
# redis_exporter['listen_address'] = 'localhost:9121'
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
## Configuration Settings for GitLab EE only ##
|
||||
|
|
|
@ -992,3 +992,13 @@ default['gitlab']['node-exporter']['flags'] = {
|
|||
'collector.textfile.directory' => File.join(node['gitlab']['node-exporter']['home'], 'textfile_collector')
|
||||
}
|
||||
default['gitlab']['node-exporter']['listen_address'] = 'localhost:9100'
|
||||
|
||||
####
|
||||
# Redis exporter
|
||||
###
|
||||
default['gitlab']['redis-exporter']['enable'] = false
|
||||
default['gitlab']['redis-exporter']['log_directory'] = "/var/log/gitlab/redis-exporter"
|
||||
default['gitlab']['redis-exporter']['flags'] = {
|
||||
'redis.addr' => "unix://#{node['gitlab']['gitlab-rails']['redis_socket']}",
|
||||
}
|
||||
default['gitlab']['redis-exporter']['listen_address'] = 'localhost:9121'
|
||||
|
|
|
@ -82,6 +82,7 @@ module Gitlab
|
|||
registry Mash.new
|
||||
node_exporter Mash.new
|
||||
prometheus Mash.new
|
||||
redis_exporter Mash.new
|
||||
sentinel Mash.new
|
||||
node nil
|
||||
external_url nil
|
||||
|
@ -197,10 +198,11 @@ module Gitlab
|
|||
"pages_external_url",
|
||||
"gitlab_pages",
|
||||
"registry",
|
||||
"sentinel",
|
||||
"gitaly",
|
||||
"node_exporter",
|
||||
"prometheus"
|
||||
"prometheus",
|
||||
"redis_exporter",
|
||||
"sentinel"
|
||||
].each do |key|
|
||||
rkey = key.gsub('_', '-')
|
||||
results['gitlab'][rkey] = Gitlab[key]
|
||||
|
|
|
@ -52,6 +52,7 @@ module Logging
|
|||
registry
|
||||
node_exporter
|
||||
prometheus
|
||||
redis_exporter
|
||||
}.each do |runit_sv|
|
||||
Gitlab[runit_sv.gsub('-', '_')]['svlogd_prefix'] ||= "#{Gitlab['node']['hostname']} #{runit_sv}: "
|
||||
end
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
# Configure Prometheus Services
|
||||
[
|
||||
"prometheus",
|
||||
"node-exporter"
|
||||
"node-exporter",
|
||||
"redis-exporter"
|
||||
].each do |service|
|
||||
if node["gitlab"][service]["enable"]
|
||||
include_recipe "gitlab::#{service}"
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#
|
||||
# Copyright:: Copyright (c) 2012 Opscode, Inc.
|
||||
# Copyright:: Copyright (c) 2017 GitLab Inc.
|
||||
# License:: Apache License, Version 2.0
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
account_helper = AccountHelper.new(node)
|
||||
redis_user = account_helper.redis_user
|
||||
redis_exporter_log_dir = node['gitlab']['redis-exporter']['log_directory']
|
||||
|
||||
directory redis_exporter_log_dir do
|
||||
owner redis_user
|
||||
mode '0700'
|
||||
recursive true
|
||||
end
|
||||
|
||||
runtime_flags = PrometheusHelper.new(node).flags('redis-exporter')
|
||||
runit_service 'redis-exporter' do
|
||||
options({
|
||||
log_directory: redis_exporter_log_dir,
|
||||
flags: runtime_flags
|
||||
}.merge(params))
|
||||
log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['registry'].to_hash)
|
||||
end
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#
|
||||
# Copyright:: Copyright (c) 2012 Opscode, Inc.
|
||||
# Copyright:: Copyright (c) 2016 GitLab Inc.
|
||||
# License:: Apache License, Version 2.0
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
runit_service 'redis-exporter' do
|
||||
action :disable
|
||||
end
|
|
@ -11,3 +11,8 @@ scrape_configs:
|
|||
static_configs:
|
||||
- targets: ['<%= node['gitlab']['node-exporter']['listen_address'] %>']
|
||||
<% end -%>
|
||||
<% if node['gitlab']['redis-exporter']['enable'] %>
|
||||
- job_name: redis
|
||||
static_configs:
|
||||
- targets: ['<%= node['gitlab']['redis-exporter']['listen_address'] %>']
|
||||
<% end -%>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<%= "s#@svlogd_size" if @svlogd_size %>
|
||||
<%= "n#@svlogd_num" if @svlogd_num %>
|
||||
<%= "t#@svlogd_timeout" if @svlogd_timeout %>
|
||||
<%= "!#@svlogd_filter" if @svlogd_filter %>
|
||||
<%= "u#@svlogd_udp" if @svlogd_udp %>
|
||||
<%= "p#@svlogd_prefix" if @svlogd_prefix %>
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
exec svlogd -tt <%= @options[:log_directory] %>
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
exec 2>&1
|
||||
<%= render("mount_point_check.erb") %>
|
||||
umask 077
|
||||
exec chpst -P -U <%= node['gitlab']['redis']['username'] %>:<%= node['gitlab']['user']['group'] %> -u <%= node['gitlab']['redis']['username'] %>:<%= node['gitlab']['user']['group'] %> /opt/gitlab/embedded/bin/redis_exporter <%= @options[:flags] %>
|
|
@ -0,0 +1,58 @@
|
|||
require 'chef_helper'
|
||||
|
||||
describe 'gitlab::redis-exporter' do
|
||||
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab::default') }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:[]).and_call_original
|
||||
end
|
||||
|
||||
context 'when redis-exporter is enabled' do
|
||||
let(:config_template) { chef_run.template('/var/log/gitlab/redis-exporter/config') }
|
||||
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis_exporter: { enable: true }
|
||||
)
|
||||
end
|
||||
|
||||
it_behaves_like 'enabled runit service', 'redis-exporter', 'root', 'root'
|
||||
|
||||
it 'populates the files with expected configuration' do
|
||||
expect(config_template).to notify('ruby_block[reload redis-exporter svlogd configuration]')
|
||||
|
||||
expect(chef_run).to render_file('/opt/gitlab/sv/redis-exporter/run')
|
||||
.with_content { |content|
|
||||
expect(content).to match(/exec chpst -P/)
|
||||
expect(content).to match(/\/opt\/gitlab\/embedded\/bin\/redis_exporter/)
|
||||
}
|
||||
|
||||
expect(chef_run).to render_file('/opt/gitlab/sv/redis-exporter/log/run')
|
||||
.with_content(/exec svlogd -tt \/var\/log\/gitlab\/redis-exporter/)
|
||||
end
|
||||
|
||||
it 'creates default set of directories' do
|
||||
expect(chef_run).to create_directory('/var/log/gitlab/redis-exporter').with(
|
||||
owner: 'gitlab-redis',
|
||||
group: nil,
|
||||
mode: '0700'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when log dir is changed' do
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis_exporter: {
|
||||
log_directory: 'foo',
|
||||
enable: true
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
it 'populates the files with expected configuration' do
|
||||
expect(chef_run).to render_file('/opt/gitlab/sv/redis-exporter/log/run')
|
||||
.with_content(/exec svlogd -tt foo/)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue