[metrics] blackbox exporter icmp
diff --git a/lotus-land-story/templates/scrape.yml b/lotus-land-story/templates/scrape.yml
index f27002e..e5ccfb2 100644
--- a/lotus-land-story/templates/scrape.yml
+++ b/lotus-land-story/templates/scrape.yml
@@ -30,6 +30,46 @@ scrape_configs:
- target_label: __address__
replacement: mountain-of-faith:9115
+ - job_name: blackbox-exporter-http
+ metrics_path: /probe
+ params:
+ module: [ http ]
+ static_configs:
+ - targets:
+ - https://www.facebook.com
+ - https://www.google.com
+ - https://www.linuxserver.io
+ - https://www.youtube.com
+ relabel_configs:
+ - source_labels: [__address__]
+ target_label: __param_target
+ - source_labels: [__param_target]
+ target_label: instance
+ - source_labels: [__param_target]
+ target_label: target # for the dashboard
+ - target_label: __address__
+ replacement: mountain-of-faith:9115
+
+ - job_name: blackbox-exporter-icmp
+ metrics_path: /probe
+ params:
+ module: [ icmp ]
+ static_configs:
+ - targets:
+ - facebook.com
+ - google.com
+ - linuxserver.io
+ - youtube.com
+ relabel_configs:
+ - source_labels: [__address__]
+ target_label: __param_target
+ - source_labels: [__param_target]
+ target_label: instance
+ - source_labels: [__param_target]
+ target_label: target # for the dashboard
+ - target_label: __address__
+ replacement: mountain-of-faith:9115
+
- job_name: cadvisor
scrape_interval: 5s
static_configs:
diff --git a/mountain-of-faith/main.yml b/mountain-of-faith/main.yml
index aa32f0a..801b60f 100644
--- a/mountain-of-faith/main.yml
+++ b/mountain-of-faith/main.yml
@@ -19,7 +19,6 @@
update_cache: true
loop:
- neovim
- - prometheus-node-exporter
- name: Update all packages to their latest version
ansible.builtin.apt:
@@ -127,11 +126,19 @@
- import_playbook: syncthing.yml
- name: Set up metrics
- tags: blackbox
+ tags: metrics
hosts: mountain-of-faith
become: true
tasks:
+ - name: Install blackbox-exporter
+ ansible.builtin.apt:
+ name: "{{ item }}"
+ state: present
+ loop:
+ - prometheus-blackbox-exporter
+ - prometheus-node-exporter
+
- name: Create Blackbox config directory
ansible.builtin.file:
path: /mnt/mountain-of-faith/blackbox-exporter
@@ -143,12 +150,6 @@
dest: /mnt/mountain-of-faith/blackbox-exporter/blackbox.yml
content: |
modules:
- http:
- prober: http
- http:
- preferred_ip_protocol: ip4
- http_ipv6:
- prober: http
dns:
prober: dns
dns:
@@ -160,33 +161,38 @@
dns:
query_name: kejadlen.dev
query_type: A # https://blog.cloudflare.com/rfc8482-saying-goodbye-to-any/
+ http:
+ prober: http
+ http:
+ preferred_ip_protocol: ip4
+ http_ipv6:
+ prober: http
+ icmp:
+ prober: icmp
+ timeout: 5s
+ icmp:
+ preferred_ip_protocol: "ip4"
mode: "0644"
notify: restart blackbox-exporter
- - name: Run Blackbox exporter container
- community.docker.docker_container:
- name: blackbox-exporter
- image: quay.io/prometheus/blackbox-exporter:latest
- ports:
- - "9115:9115"
- networks:
- - name: mountain-of-faith
- volumes:
- - "/mnt/mountain-of-faith/blackbox-exporter:/config:ro"
- command:
- - --config.file=/config/blackbox.yml
- # - --log.level=debug
- # - --log.prober=debug
- restart_policy: unless-stopped
- state: started
+ - name: Configure blackbox-exporter service
+ ansible.builtin.lineinfile:
+ path: /etc/default/prometheus-blackbox-exporter
+ regexp: '^ARGS='
+ line: 'ARGS="--config.file=/mnt/mountain-of-faith/blackbox-exporter/blackbox.yml"'
+ notify: restart blackbox-exporter
- handlers:
- - name: Restart Blackbox exporter
- community.docker.docker_container:
- name: blackbox-exporter
- restart: true
+ # Not sure if this actually works, but can alternatively use
+ # `dpkg-reconfigure prometheus-blackbox-exporter`
+ - name: Enable ICMP capabilities for blackbox-exporter
+ ansible.builtin.command: setcap cap_net_raw+ep /usr/bin/prometheus-blackbox-exporter
+ changed_when: false
+ notify: restart blackbox-exporter
-# TODO caddy?
-# TODO node-exporter
+ handlers:
+ - name: restart blackbox-exporter
+ ansible.builtin.systemd:
+ name: prometheus-blackbox-exporter
+ state: restarted
# vim: ft=yaml.ansible