Skip to content

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

@daytonpa

Description

@daytonpa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions