Skip to content

Commit 1bc6b31

Browse files
committed
refactored to make easier to extend with new probes
1 parent 6e780c0 commit 1bc6b31

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

ansible/roles/kube_prometheus_stack/defaults/main/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ kube_prometheus_stack_blackbox_exporter_release_version: 9.0.1
2424
kube_prometheus_stack_blackbox_exporter_image_tag: v0.25.0
2525
kube_prometheus_stack_blackbox_exporter_release_name: blackbox-exporter
2626

27+
kube_prometheus_stack_blackbox_modules: {}
28+
2729
control_ip: "{{ hostvars[groups['control'].0].ansible_host }}"
2830

2931
grafana_auth_anonymous: false

ansible/roles/kube_prometheus_stack/tasks/main.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
name: grafana-dashboards
178178

179179
- name: Install blackbox exporter helm chart
180-
no_log: true
180+
no_log: true # may expose testuser password
181181
kubernetes.core.helm:
182182
chart_ref: prometheus-blackbox-exporter
183183
chart_repo_url: https://prometheus-community.github.io/helm-charts
@@ -188,14 +188,7 @@
188188
nodeSelector:
189189
clusterrole: "server"
190190
config:
191-
modules:
192-
http_2xx:
193-
http:
194-
tls_config:
195-
insecure_skip_verify: true
196-
basic_auth:
197-
username: "testuser"
198-
password: "{{ vault_testuser_password }}"
191+
modules: "{{ kube_prometheus_stack_blackbox_modules }}"
199192
configReloader:
200193
image:
201194
tag: "{{ kube_prometheus_stack_app_version }}" # keeps consistent with pre-pulled image for kube-prometheus-stack
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Note: underlying helm chart is configured with a default module 'http_2xx', defining modules with this name here will merge the module's values with the existing module,
2+
# see https://github.com/prometheus-community/helm-charts/blob/main/charts/prometheus-blackbox-exporter/values.yaml#L163
3+
kube_prometheus_stack_blackbox_modules_defaults: {}
4+
5+
kube_prometheus_stack_blackbox_modules: "{{ kube_prometheus_stack_blackbox_modules_defaults if ( groups['openondemand'] | count == 0 ) else ( kube_prometheus_stack_blackbox_modules_defaults | combine(openondemand_blackbox_modules) ) }}"
6+
7+
# See prometheus_scrape_configs in prometheus.yml to add additional scrape jobs to probe services

environments/common/inventory/group_vars/all/openondemand.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ openondemand_scrape_configs:
182182
labels:
183183
environment: "{{ appliances_environment_name }}"
184184
service: "openondemand"
185-
- job_name: "blackbox-probes"
185+
- job_name: "ood-blackbox-probe"
186186
metrics_path: /probe
187187
params:
188-
module: [http_2xx]
188+
module: [ood_http_2xx]
189189
static_configs:
190190
- targets:
191191
- "{{ openondemand_address }}"
@@ -197,6 +197,20 @@ openondemand_scrape_configs:
197197
- target_label: __address__
198198
replacement: "{{ kube_prometheus_stack_blackbox_exporter_release_name }}-prometheus-blackbox-exporter:9115"
199199

200+
openondemand_blackbox_modules:
201+
ood_http_2xx:
202+
prober: http
203+
timeout: 5s
204+
http:
205+
valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
206+
follow_redirects: true
207+
preferred_ip_protocol: "ip4"
208+
tls_config:
209+
insecure_skip_verify: true
210+
basic_auth:
211+
username: "testuser"
212+
password: "{{ vault_testuser_password }}"
213+
200214
openondemand_dashboard:
201215
- dashboard_id: 13465
202216
replacements:

0 commit comments

Comments
 (0)