diff options
4 files changed, 36 insertions, 34 deletions
diff --git a/inventory/group_vars/chaos-at-home-ups/vars.yml b/inventory/group_vars/chaos-at-home-ups/vars.yml index 31be4572..5c0de008 100644 --- a/inventory/group_vars/chaos-at-home-ups/vars.yml +++ b/inventory/group_vars/chaos-at-home-ups/vars.yml @@ -16,6 +16,5 @@ prometheus_exporters_default: prometheus_job_multitarget_nut__ups: ch-mon: - - instance: "ups-{{ ups_name }}" - ups: "{{ ups_name }}" + - ups: "{{ ups_name }}" server: "{{ network_mgmt_zone.prefix | ansible.utils.ipaddr(network_mgmt_zone.offsets[inventory_hostname]) | ansible.utils.ipaddr('address') }}" diff --git a/roles/monitoring/grafana/files/dashboard-network-ups-tools.json b/roles/monitoring/grafana/files/dashboard-network-ups-tools.json index 468bae82..367e9b56 100644 --- a/roles/monitoring/grafana/files/dashboard-network-ups-tools.json +++ b/roles/monitoring/grafana/files/dashboard-network-ups-tools.json @@ -75,9 +75,9 @@ }, "id": 9, "panels": [], - "repeat": "instance", + "repeat": "ups_instance", "repeatDirection": "h", - "title": "Status: $instance", + "title": "Status: $ups_instance", "type": "row" }, { @@ -140,7 +140,7 @@ }, "editorMode": "builder", "exemplar": false, - "expr": "network_ups_tools_device_info{instance=\"$instance\"}", + "expr": "network_ups_tools_device_info{ups_instance=\"$ups_instance\"}", "instant": true, "legendFormat": "{{ mfr }}, {{ model }}", "range": false, @@ -210,7 +210,7 @@ }, "editorMode": "builder", "exemplar": false, - "expr": "network_ups_tools_ups_status{instance=\"$instance\", flag=\"OL\"}", + "expr": "network_ups_tools_ups_status{ups_instance=\"$ups_instance\", flag=\"OL\"}", "instant": true, "legendFormat": "{{ flag }}", "range": false, @@ -280,7 +280,7 @@ }, "editorMode": "builder", "exemplar": false, - "expr": "network_ups_tools_ups_status{instance=\"$instance\", flag=\"OVER\"}", + "expr": "network_ups_tools_ups_status{ups_instance=\"$ups_instance\", flag=\"OVER\"}", "instant": true, "legendFormat": "{{ flag }}", "range": false, @@ -350,7 +350,7 @@ }, "editorMode": "builder", "exemplar": false, - "expr": "network_ups_tools_ups_status{instance=\"$instance\", flag=\"OFF\"}", + "expr": "network_ups_tools_ups_status{ups_instance=\"$ups_instance\", flag=\"OFF\"}", "instant": true, "legendFormat": "{{ flag }}", "range": false, @@ -420,7 +420,7 @@ }, "editorMode": "builder", "exemplar": false, - "expr": "network_ups_tools_ups_status{instance=\"$instance\", flag=\"OB\"}", + "expr": "network_ups_tools_ups_status{ups_instance=\"$ups_instance\", flag=\"OB\"}", "instant": true, "legendFormat": "{{ flag }}", "range": false, @@ -490,7 +490,7 @@ }, "editorMode": "builder", "exemplar": false, - "expr": "network_ups_tools_ups_status{instance=\"$instance\", flag=\"LB\"}", + "expr": "network_ups_tools_ups_status{ups_instance=\"$ups_instance\", flag=\"LB\"}", "instant": true, "legendFormat": "{{ flag }}", "range": false, @@ -560,7 +560,7 @@ }, "editorMode": "builder", "exemplar": false, - "expr": "network_ups_tools_ups_status{instance=\"$instance\", flag=\"RB\"}", + "expr": "network_ups_tools_ups_status{ups_instance=\"$ups_instance\", flag=\"RB\"}", "instant": true, "legendFormat": "{{ flag }}", "range": false, @@ -669,8 +669,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_input_voltage{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_input_voltage{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -764,8 +764,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_input_frequency{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_input_frequency{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -859,8 +859,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_output_voltage{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_output_voltage{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -954,8 +954,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_output_frequency{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_output_frequency{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -1048,8 +1048,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_ups_load{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_ups_load{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -1142,8 +1142,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_ups_power{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_ups_power{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -1236,8 +1236,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_ups_realpower{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_ups_realpower{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -1330,8 +1330,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_battery_charge{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_battery_charge{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -1424,8 +1424,8 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "builder", - "expr": "network_ups_tools_battery_runtime{instance=~\"$instance\"}", - "legendFormat": "{{ instance }}", + "expr": "network_ups_tools_battery_runtime{ups_instance=~\"$ups_instance\"}", + "legendFormat": "{{ ups_instance }}", "range": true, "refId": "A" } @@ -1446,18 +1446,18 @@ "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, - "definition": "network_ups_tools_device_info", + "definition": "label_values(ups_instance)", "hide": 0, "includeAll": true, "multi": true, - "name": "instance", + "name": "ups_instance", "options": [], "query": { - "query": "network_ups_tools_device_info", - "refId": "StandardVariableQuery" + "query": "label_values(ups_instance)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" }, "refresh": 1, - "regex": "/.*instance=\"([^\"]*).*/", + "regex": "", "skipUrlSync": false, "sort": 0, "type": "query" diff --git a/roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py b/roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py index 473eb655..50e34865 100644 --- a/roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py +++ b/roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py @@ -9,6 +9,8 @@ from ansible import errors _multitarget_id_map_ = { "blackbox/probe": (lambda vars, config: (vars['inventory_hostname'], "%s-%s" % (config['svc_kind'], config['svc_instance']))), "ssl/probe": (lambda vars, config: (vars['inventory_hostname'], "%s-%s-%s" % (config['module'], config['sslcert_instance'], vars['inventory_hostname']))), + "ipmi/remote": (lambda vars, config: (vars['inventory_hostname'], vars['inventory_hostname'])), + "nut/ups": (lambda vars, config: (vars['inventory_hostname'], config['ups'])), "whawty-nginx-sso": (lambda vars, config: (vars['inventory_hostname'], "%s-%s" % (config['app_instance'], vars['inventory_hostname']))), } diff --git a/roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 index 5181f4e4..6c549e1e 100644 --- a/roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 +++ b/roles/monitoring/prometheus/exporter/register/templates/nut/ups.yml.j2 @@ -1,6 +1,7 @@ - targets: [ '{{ (target.exporter_hostname == prometheus_server) | ternary('127.0.0.1:9999', hostvars[target.exporter_hostname].prometheus_scrape_endpoint) }}' ] labels: instance: '{{ target.instance }}' + ups_instance: '{{ target.config.ups }}' __param_ups: '{{ target.config.ups }}' __param_server: '{{ target.config.server | default('127.0.0.1') }}' {% if 'username' in target.config %} |