elijah / chef-prometheus

Chef cookbook for Prometheus. The open source service monitoring system and time-series database.
Apache License 2.0
52 stars 93 forks source link

Change resource for updating Prometheus after modifying prometheus.yml #88

Open daytonpa opened 6 years ago

daytonpa commented 6 years ago

Currently, it is set to notifies :restart, 'service[prometheus]', :delayed, which isn't recommended. Further documentation is provided here. Instead, I recommend to do it this way:

# Create Prometheus configuration yml file
template '/path/to/prometheus.yml do
  owner node['prometheus']['user']
  group node['prometheus']['group']
  mode '0644'
  source 'prometheus.yml.erb'
  notifies :run, 'execute[reload_prometheus]', :delayed
end

# Reload Prometheus if configuration yml is created or modified
execute 'reload_prometheus' do
  user 'root
  group 'root
  cwd '/opt/prometheus'
  command 'curl -X POST 127.0.0.1:9090/-/reload'
  action :nothing
end

Food for thought