Skip to content

Commit

Permalink
T6949: adds dns query name option
Browse files Browse the repository at this point in the history
  • Loading branch information
nvollmar committed Dec 26, 2024
1 parent 28bf471 commit b444bbc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/templates/prometheus/blackbox_exporter.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ modules:
prober: dns
timeout: {{ module_config.timeout }}s
dns:
query_name: "{{ module_name }}"
query_name: "{{ module_config.query_name }}"
query_type: "{{ module_config.query_type }}"
preferred_ip_protocol: "{{ module_config.preferred_ip_protocol | replace('v', '') }}"
ip_protocol_fallback: {{ 'true' if module_config.ip_protocol_fallback is vyos_defined else 'false' }}
Expand Down
8 changes: 8 additions & 0 deletions interface-definitions/service_monitoring_prometheus.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
<help>Name of the dns module</help>
</properties>
<children>
<leafNode name="query-name">
<properties>
<help>Name to be queried</help>
<constraint>
<validator name="fqdn"/>
</constraint>
</properties>
</leafNode>
<leafNode name="query-type">
<properties>
<help>DNS query type</help>
Expand Down
12 changes: 12 additions & 0 deletions smoketest/scripts/cli/test_service_monitoring_prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ def test_04_blackbox_exporter_with_config(self):
'ipv4',
]
)
self.cli_set(
base_path
+ [
'blackbox-exporter',
'modules',
'dns',
'name',
'dns_ip4',
'query-name',
'vyos.io',
]
)
self.cli_set(
base_path
+ [
Expand Down
12 changes: 12 additions & 0 deletions src/conf_mode/service_monitoring_prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ def verify(monitoring):
if 'blackbox_exporter' in monitoring:
verify_vrf(monitoring['blackbox_exporter'])

if (
'modules' in monitoring['blackbox_exporter']
and 'dns' in monitoring['blackbox_exporter']['modules']
):
for mod_name, mod_config in monitoring['blackbox_exporter'][
'modules'
].items():
if 'query_name' not in mod_config:
raise ConfigError(
f'query name not specified in dns module {mod_name}'
)

return None


Expand Down

0 comments on commit b444bbc

Please sign in to comment.