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'] - targets: ['localhost:9090']
- job_name: 'node' - job_name: 'node'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
metrics_path: /node_exporter/metrics metrics_path: /node_exporter/metrics
file_sd_configs: consul_sd_configs:
- files: - server: 'localhost:8500'
- '/etc/prometheus.d/targets/targets.yml' services:
- 'node_exporter'
alerting: alerting:
alertmanagers: alertmanagers:

View File

@ -7,6 +7,15 @@ remote_file '/etc/supervisor/conf.d/node_exporter.conf' do
notifies :restart, 'service[supervisor]' notifies :restart, 'service[supervisor]'
end 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 service 'supervisor' do
action :nothing action :nothing
end end