Skip to content
Snippets Groups Projects
Commit 60c48bc4 authored by Ben Kochie's avatar Ben Kochie
Browse files

Add a rules file for the node_exporter

* Include the upstream[0] example rules file.
* Trigger HUP of prometheus server.
* Update `node_exporter` spec.

[0]: https://github.com/prometheus/node_exporter/blob/master/example.rules
parent 0ea981bc
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -895,6 +895,7 @@ default['gitlab']['prometheus']['target_heap_size'] = (
# Use 25mb + 2% of total memory for Prometheus memory.
26_214_400 + (node['memory']['total'].to_i * 1024 * 0.02)
).to_i
default['gitlab']['prometheus']['rules_files'] = []
 
####
# Prometheus Node Exporter
Loading
Loading
Loading
Loading
@@ -16,6 +16,7 @@
# limitations under the License.
#
account_helper = AccountHelper.new(node)
prometheus_dir = node['gitlab']['prometheus']['home']
prometheus_user = account_helper.prometheus_user
node_exporter_log_dir = node['gitlab']['node-exporter']['log_directory']
textfile_dir = File.join(node['gitlab']['node-exporter']['home'], 'textfile_collector')
Loading
Loading
@@ -52,3 +53,14 @@ if node['gitlab']['bootstrap']['enable']
retries 20
end
end
node_rules_file = File.join(prometheus_dir, 'node.rules')
node.default['gitlab']['prometheus']['rules_files'] << node_rules_file
template node_rules_file do
source 'prometheus/rules/node.rules.erb'
owner prometheus_user
mode '0644'
only_if { node['gitlab']['prometheus']['enable'] }
end
# The count of CPUs per node, useful for getting CPU time as a percent of total.
instance:node_cpus:count = count(node_cpu{mode="idle"}) without (cpu,mode)
# CPU in use by CPU.
instance_cpu:node_cpu_not_idle:rate5m = sum(rate(node_cpu{mode!="idle"}[5m])) without (mode)
# CPU in use by mode.
instance_mode:node_cpu:rate5m = sum(rate(node_cpu[5m])) without (cpu)
Loading
Loading
@@ -64,6 +64,20 @@ describe 'gitlab::node-exporter' do
end
end
 
context 'when node-exporter is enabled and prometheus is enabled' do
before do
stub_gitlab_rb(
prometheus: { enable: true },
node_exporter: { enable: true }
)
end
it 'creates a node.rules file' do
expect(chef_run).to render_file('/var/opt/gitlab/prometheus/node.rules')
.with_content(/instance:node_cpus:count/)
end
end
context 'when log dir is changed' do
before do
stub_gitlab_rb(
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment