From a8e8cb2ed3d5e68d89edd8785ed59f0ee45f81bf Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 21 Sep 2021 19:34:25 +0200 Subject: prometheus: simplify job config --- .../prometheus/server/templates/targets/generic.yml.j2 | 4 ++-- .../prometheus/server/templates/targets/nut-ups.yml.j2 | 17 +++++++++++++++++ .../prometheus/server/templates/targets/nut.yml.j2 | 17 ----------------- 3 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 roles/monitoring/prometheus/server/templates/targets/nut-ups.yml.j2 delete mode 100644 roles/monitoring/prometheus/server/templates/targets/nut.yml.j2 (limited to 'roles/monitoring/prometheus/server/templates/targets') diff --git a/roles/monitoring/prometheus/server/templates/targets/generic.yml.j2 b/roles/monitoring/prometheus/server/templates/targets/generic.yml.j2 index e83b6bf4..45af10c0 100644 --- a/roles/monitoring/prometheus/server/templates/targets/generic.yml.j2 +++ b/roles/monitoring/prometheus/server/templates/targets/generic.yml.j2 @@ -1,3 +1,3 @@ -- targets: [ "{{ hostvars[target].prometheus_scrape_endpoint }}" ] +- targets: [ "{{ hostvars[target.instance].prometheus_scrape_endpoint }}" ] labels: - instance: "{{ target }}" + instance: "{{ target.instance }}" diff --git a/roles/monitoring/prometheus/server/templates/targets/nut-ups.yml.j2 b/roles/monitoring/prometheus/server/templates/targets/nut-ups.yml.j2 new file mode 100644 index 00000000..da3de3d7 --- /dev/null +++ b/roles/monitoring/prometheus/server/templates/targets/nut-ups.yml.j2 @@ -0,0 +1,17 @@ +- targets: [ "{{ hostvars[target.config.exporter_hostname].prometheus_scrape_endpoint }}" ] + labels: + instance: "{{ target.instance }}" + __param_ups: {{ target.config.ups }} + __param_server: {{ target.config.server | default('127.0.0.1') }} +{% if 'username' in target.config %} + __param_username: {{ target.config.username }} +{% endif %} +{% if 'password' in target.config %} + __param_password: {{ target.config.password }} +{% endif %} +{% if 'variables' in target.config %} + __param_variables: {{ target.config.variables }} +{% endif %} +{% if 'statuses' in target.config %} + __param_statuses: {{ target.config.statuses }} +{% endif %} diff --git a/roles/monitoring/prometheus/server/templates/targets/nut.yml.j2 b/roles/monitoring/prometheus/server/templates/targets/nut.yml.j2 deleted file mode 100644 index da3de3d7..00000000 --- a/roles/monitoring/prometheus/server/templates/targets/nut.yml.j2 +++ /dev/null @@ -1,17 +0,0 @@ -- targets: [ "{{ hostvars[target.config.exporter_hostname].prometheus_scrape_endpoint }}" ] - labels: - instance: "{{ target.instance }}" - __param_ups: {{ target.config.ups }} - __param_server: {{ target.config.server | default('127.0.0.1') }} -{% if 'username' in target.config %} - __param_username: {{ target.config.username }} -{% endif %} -{% if 'password' in target.config %} - __param_password: {{ target.config.password }} -{% endif %} -{% if 'variables' in target.config %} - __param_variables: {{ target.config.variables }} -{% endif %} -{% if 'statuses' in target.config %} - __param_statuses: {{ target.config.statuses }} -{% endif %} -- cgit v1.2.3