Use `consul` service discovery to register `prometheus` monitoring.

This commit is contained in:
Kazuhiro MUSASHI 2020-09-23 23:40:12 +09:00
parent c13954bfc9
commit 70e78a2af0
3 changed files with 19 additions and 6 deletions

View File

@ -0,0 +1,6 @@
{
"service": {
"name": "node_exporter",
"port": 60000
}
}

View File

@ -44,14 +44,12 @@ scrape_configs:
- targets: ['localhost:9090']
- job_name: 'node'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
metrics_path: /node_exporter/metrics
file_sd_configs:
- files:
- '/etc/prometheus.d/targets/targets.yml'
consul_sd_configs:
- server: 'localhost:8500'
services:
- 'node_exporter'
alerting:
alertmanagers:

View File

@ -7,6 +7,15 @@ remote_file '/etc/supervisor/conf.d/node_exporter.conf' do
notifies :restart, 'service[supervisor]'
end
# Deploy `consul` config for `node_exporter`:
remote_file '/etc/consul.d/service-node_exporter.json' do
owner 'root'
group 'root'
mode '644'
notifies :restart, 'service[supervisor]'
end
service 'supervisor' do
action :nothing
end