use file for node-targets
This commit is contained in:
parent
5ae367f05e
commit
3d094d13eb
3 changed files with 30 additions and 5 deletions
|
@ -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
|
||||||
|
|
6
roles/prometheus/templates/node-targets.json
Normal file
6
roles/prometheus/templates/node-targets.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"targets": [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
|
@ -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'
|
||||||
|
|
Loading…
Reference in a new issue