summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py20
-rw-r--r--roles/monitoring/prometheus/exporter/register/templates/modbus/probe.yml.j21
-rw-r--r--roles/monitoring/prometheus/exporter/register/templates/snmp/probe.yml.j21
3 files changed, 11 insertions, 11 deletions
diff --git a/roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py b/roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py
index 50e34865..76e47056 100644
--- a/roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py
+++ b/roles/monitoring/prometheus/exporter/register/filter_plugins/prometheus.py
@@ -7,11 +7,13 @@ 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']))),
+ "blackbox/probe": (lambda vars, config: "%s-%s" % (config['svc_kind'], config['svc_instance'])),
+ "ssl/probe": (lambda vars, config: "%s-%s-%s" % (config['module'], config['sslcert_instance'], vars['inventory_hostname'])),
+ "ipmi/remote": (lambda vars, config: vars['inventory_hostname']),
+ "nut/ups": (lambda vars, config: config['ups']),
+ "snmp/probe": (lambda vars, config: config['snmp_instance']),
+ "modbus/probe": (lambda vars, config: config['modbus_instance']),
+ "whawty-nginx-sso": (lambda vars, config: "%s-%s" % (config['app_instance'], vars['inventory_hostname'])),
}
@@ -23,12 +25,8 @@ def prometheus_job_targets(jobs, vars):
if multitarget_config_varname in vars:
for exporter_hostname, configs in vars[multitarget_config_varname].items():
for config in configs:
- if job in _multitarget_id_map_:
- instance, id = _multitarget_id_map_[job](vars, config)
- else:
- id = config['instance']
- instance = config['instance']
- result.append({'_id': id, 'job': job, 'instance': instance, 'enabled': True,
+ id = _multitarget_id_map_[job](vars, config)
+ result.append({'_id': id, 'job': job, 'instance': vars['inventory_hostname'], 'enabled': True,
'exporter_hostname': exporter_hostname, 'config': config})
else:
diff --git a/roles/monitoring/prometheus/exporter/register/templates/modbus/probe.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/modbus/probe.yml.j2
index 5d51398a..d450f535 100644
--- a/roles/monitoring/prometheus/exporter/register/templates/modbus/probe.yml.j2
+++ b/roles/monitoring/prometheus/exporter/register/templates/modbus/probe.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 }}'
+ modbus_instance: '{{ target.config.modbus_instance }}'
__param_target: '{{ target.config.target }}'
__param_sub_target: '{{ target.config.sub_target }}'
__param_module: '{{ target.config.module }}'
diff --git a/roles/monitoring/prometheus/exporter/register/templates/snmp/probe.yml.j2 b/roles/monitoring/prometheus/exporter/register/templates/snmp/probe.yml.j2
index a50a32ff..90b70003 100644
--- a/roles/monitoring/prometheus/exporter/register/templates/snmp/probe.yml.j2
+++ b/roles/monitoring/prometheus/exporter/register/templates/snmp/probe.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 }}'
+ snmp_instance: '{{ target.config.snmp_instance }}'
__param_target: '{{ target.config.target }}'
__param_module: '{{ target.config.module }}'
{% if 'auth' in target.config %}