Skip to content

Commit

Permalink
make tor_gen_blackbox_scrape_config obsolete
Browse files Browse the repository at this point in the history
by using tor_blackbox_exporter_host as a signal
to enable blackbox exporter scrape configs

changes the default value of tor_blackbox_exporter_host
from
localhost:9115
to
undefined

so the user has to opt-in for blackbox exporter (as it always was)
  • Loading branch information
nusenu committed Feb 12, 2023
1 parent af2ad43 commit 84bc7b6
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 27 deletions.
23 changes: 9 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,7 @@ All variables mentioned here are optional.
- default: False

* `tor_prometheus_host` hostname
- only relevant if `tor_enableMetricsPort` or `tor_gen_blackbox_scrape_config` is True
- this variable is only relevant if `tor_enableMetricsPort` or `tor_gen_blackbox_scrape_config` is True
- this variable is only relevant if `tor_enableMetricsPort` or `tor_blackbox_exporter_host` is set
- if you want to enable relayor's prometheus integration you have to set this variable to your prometheus host
- it defines on which host ansible should generate the prometheus scrape configuration to scrape tor's MetricsPort
- this host must be available in ansible's inventory file
Expand Down Expand Up @@ -305,11 +304,11 @@ All variables mentioned here are optional.
- default: 33300

* `tor_prometheus_scrape_file` filename
- only relevant if `tor_prometheus_host` is defined and `tor_enableMetricsPort` or `tor_gen_blackbox_scrape_config` is True
- only relevant if `tor_prometheus_host` is defined and `tor_enableMetricsPort` or `tor_blackbox_exporter_host` is set
- defines the filename for per server [scrape_config](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) files
on the prometheus server inside the `tor_prometheus_confd_folder`
- the filename MUST be host specific, each host has its own scrape config file on the prometheus server to support the ansible-playbook `--limit` cli option
- depending on `tor_enableMetricsPort` and `tor_gen_blackbox_scrape_config`, the scrape config files will contain scrape jobs for the tor
- depending on `tor_enableMetricsPort` and `tor_blackbox_exporter_host`, the scrape config files will contain scrape jobs for the tor
MetricsPort (behind a reverse proxy for TLS/basic auth) and/or scrape jobs for ORPort/DirPort TCP probes via blackbox exporter
- the file content is sensitive (contains scrape credentials) and gets these file permissions: 0640 (owner: root, group: `tor_prometheus_group`)
- the generated scrape config files will automatically be enriched with a few useful prometheus labels depending on your torrc settings, see the "Prometheus Labels" section in this README
Expand All @@ -326,30 +325,26 @@ All variables mentioned here are optional.
- for an example see `defaults/main.yml`
- default: empty dictionary

* `tor_gen_blackbox_scrape_config` boolean
- when set to True we add the necessary prometheus scrape config for blackbox exporter TCP propes in the file defined by `tor_prometheus_scrape_file`
- if True you also have to set `tor_prometheus_scrape_file` otherwise no scrape config file is generated
* `tor_blackbox_exporter_host` hostname:port
- when set we add the necessary prometheus scrape config for blackbox exporter TCP propes in the file defined by `tor_prometheus_scrape_file`
- we monitor all relay ORPorts and when set DirPorts on IPv4 and IPv6 (if enabled)
- this feature is not supported on relays behind NAT
- default: False

* `tor_blackbox_exporter_host` hostname:port
- only relevant when `tor_gen_blackbox_scrape_config` is True
- defines where prometheus finds the blackbox exporter
- defines where prometheus finds the blackbox exporter, it can also run on the prometheus server itself, in that case it would be 127.0.0.1:9115
- the host is written into the resulting prometheus scrape config
- default: localhost:9115
- default: undefined

* `tor_blackbox_exporter_scheme` string
- defines the protocol prometheus uses to connect to the blackbox exporter (http or https)
- default: http

* `tor_blackbox_exporter_username` string
- only relevant when `tor_blackbox_exporter_host` is set
- allows you to define the username if your blackbox exporter requires HTTP basic authentication
- if you do not set a username the scrape config will not include HTTP basic auth credentials
- default: undefined (no HTTP basic auth)

* `tor_blackbox_exporter_password` string
- only relevant when `tor_gen_blackbox_scrape_config` is True
- only relevant when `tor_blackbox_exporter_host` is set
- allows you to the the username if your blackbox exporter requires HTTP basic auth
- the default generates a 20 character random string using the Ansible password lookup
- default: `"{{ lookup('password', '~/.tor/prometheus/blackbox_exporter_password') }}"`
Expand Down
3 changes: 0 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,9 @@ tor_enableMetricsPort: False
tor_MetricsPort_offset: 33300

# prometheus (tor MetricsPort) related vars
tor_blackbox_exporter_host: localhost:9115
tor_prometheus_group: prometheus
tor_gen_blackbox_scrape_config: False
tor_blackbox_exporter_scheme: http
tor_blackbox_exporter_password: "{{ lookup('password', '~/.tor/blackbox_exporter_password') }}"

tor_prometheus_scrape_password_folder: "~/.tor/prometheus/scrape-passwords/"
tor_prometheus_scrape_port: 443
tor_gen_metricsport_htpasswd: True
Expand Down
2 changes: 1 addition & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
group: "{{ tor_prometheus_group }}"
mode: 0640
delegate_to: "{{ tor_prometheus_host }}"
when: (tor_enableMetricsPort or tor_gen_blackbox_scrape_config) and tor_prometheus_host is defined
when: (tor_enableMetricsPort or tor_blackbox_exporter_host) and tor_prometheus_host is defined
notify:
- assemble prometheus configuration
- reload prometheus
Expand Down
2 changes: 1 addition & 1 deletion templates/prometheus-scrape-configs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{% endfor %}
{% endfor %}
{% endif %}
{% if tor_gen_blackbox_scrape_config %}
{% if tor_blackbox_exporter_host is defined %}
- job_name: 'tor-blackbox_tcp_connect_{{ansible_fqdn}}'
metrics_path: /probe
scheme: '{{ tor_blackbox_exporter_scheme }}'
Expand Down
2 changes: 1 addition & 1 deletion test/integration/default/2publicIPs-guard-metricsport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- tor_maxPublicIPs: 2
- tor_enableMetricsPort: True
- tor_metricsport_nginx_config_file: /tmp/web-reverse-proxy-{{ inventory_hostname }}
- tor_gen_blackbox_scrape_config: True
- tor_blackbox_exporter_host: 127.0.0.1:9115
- tor_prometheus_host: 127.0.0.1
roles:
- "{{ playbook_dir | regex_replace('test/integration/default$') }}"
2 changes: 1 addition & 1 deletion test/integration/default/2publicIPs-guard4-metricsport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
tor_maxPublicIPs: 2
tor_enableMetricsPort: True
tor_metricsport_nginx_config_file: /tmp/web-reverse-proxy-{{ inventory_hostname }}
tor_gen_blackbox_scrape_config: True
tor_blackbox_exporter_host: 127.0.0.1:9115
tor_prometheus_host: 127.0.0.1
tor_ports:
- orport: 9000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- tor_alpha: True
- tor_enableMetricsPort: True
- tor_metricsport_nginx_config_file: /tmp/web-reverse-proxy-{{ inventory_hostname }}
- tor_gen_blackbox_scrape_config: True
- tor_blackbox_exporter_host: 127.0.0.1:9115
- tor_prometheus_host: 127.0.0.1
roles:
- "{{ playbook_dir | regex_replace('test/integration/default$') }}"
2 changes: 1 addition & 1 deletion test/integration/default/guard-blackbox-exporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
vars_files:
- vars/dry-run-vars.yml
vars:
- tor_gen_blackbox_scrape_config: True
- tor_blackbox_exporter_username: testuser
- tor_blackbox_exporter_host: 127.0.0.1:9115
- tor_prometheus_host: 127.0.0.1
roles:
- "{{ playbook_dir | regex_replace('test/integration/default$') }}"
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
vars:
- tor_enableMetricsPort: True
- tor_metricsport_nginx_config_file: /tmp/web-reverse-proxy-{{ inventory_hostname }}
- tor_gen_blackbox_scrape_config: True
- tor_gen_prometheus_alert_rules: True
- tor_blackbox_exporter_host: 127.0.0.1:9115
- tor_prometheus_host: 127.0.0.1
- tor_prom_labels:
label1: "value1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
vars:
- tor_enableMetricsPort: True
- tor_metricsport_nginx_config_file: /tmp/web-reverse-proxy-{{ inventory_hostname }}
- tor_gen_blackbox_scrape_config: True
- tor_gen_prometheus_alert_rules: True
- tor_blackbox_exporter_host: 127.0.0.1:9115
- tor_prometheus_host: 127.0.0.1
- tor_prom_labels:
label1: "value1"
Expand Down
2 changes: 1 addition & 1 deletion test/integration/default/guard-metricsport-blackbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
vars:
- tor_enableMetricsPort: True
- tor_metricsport_nginx_config_file: /tmp/web-reverse-proxy-{{ inventory_hostname }}
- tor_gen_blackbox_scrape_config: True
- tor_blackbox_exporter_host: 127.0.0.1:9115
- tor_prometheus_host: 127.0.0.1
- tor_prom_labels:
label1: "value1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- tor_nightly_builds: True
- tor_enableMetricsPort: True
- tor_metricsport_nginx_config_file: /tmp/web-reverse-proxy-{{ inventory_hostname }}
- tor_gen_blackbox_scrape_config: True
- tor_blackbox_exporter_host: 127.0.0.1:9115
- tor_prometheus_host: 127.0.0.1
roles:
- "{{ playbook_dir | regex_replace('test/integration/default$') }}"

0 comments on commit 84bc7b6

Please sign in to comment.