use file for node-targets

This commit is contained in:
histausse 2021-09-21 12:04:22 +02:00
parent 5ae367f05e
commit 3d094d13eb
Signed by: histausse
GPG key ID: 67486F107F62E9E9
3 changed files with 30 additions and 5 deletions

View file

@ -29,7 +29,18 @@
notify: Restart prometheus notify: Restart prometheus
no_log: true no_log: true
- name: Setup the arguments for node-exporter - name: Add node targets file
template:
src: node-targets.json
dest: /etc/prometheus/node-targets.json
owner: prometheus
group: prometheus
mode: '0640'
force: no
notify: Restart prometheus
no_log: true
- name: Setup the arguments for prometheus
template: template:
src: prometheus src: prometheus
dest: /etc/default/prometheus dest: /etc/default/prometheus

View file

@ -0,0 +1,6 @@
[
{
"targets": [
]
}
]

View file

@ -33,7 +33,15 @@ scrape_configs:
- targets: ['{{ lan_address }}:9090'] - targets: ['{{ lan_address }}:9090']
- job_name: node - job_name: node
# If prometheus-node-exporter is installed, grab stats about the local file_sd_configs:
# machine by default. - files:
static_configs: - '/etc/prometheus/node-targets.json'
- targets: ['{{ lan_address }}:9100'] relabel_configs:
# Do not put :9100 in instance name, rather here
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- source_labels: [__param_target]
target_label: __address__
replacement: '$1:9100'