aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar shtlrs <[email protected]>2024-05-04 17:48:31 +0200
committerGravatar jchristgit <[email protected]>2024-05-06 13:37:59 +0200
commit29138efe3a47574e55f22a6d71b4ef1d038a67c5 (patch)
treecd9c683d94e52fae630fad602d96d289e6ad68f1
parentPerform fail2ban bans directly via nftables (diff)
install blackbox exporter as part of out monitoring stack
-rw-r--r--ansible/host_vars/lovelace/prometheus.yml38
-rw-r--r--ansible/playbook.yml1
-rw-r--r--ansible/roles/prometheus-blackbox-exporter/README.md3
-rw-r--r--ansible/roles/prometheus-blackbox-exporter/tasks/main.yaml7
-rw-r--r--ansible/roles/prometheus/defaults/main.yml47
5 files changed, 49 insertions, 47 deletions
diff --git a/ansible/host_vars/lovelace/prometheus.yml b/ansible/host_vars/lovelace/prometheus.yml
index d148bf1..1e4ec40 100644
--- a/ansible/host_vars/lovelace/prometheus.yml
+++ b/ansible/host_vars/lovelace/prometheus.yml
@@ -35,3 +35,41 @@ prometheus_configuration:
# Scrape node exporters on all hosts
static_configs:
- targets: "{{ hostvars.values() | map(attribute='ansible_wg0.ipv4.address') | map('regex_replace', '^(.*)$', '\\1:9100') | list }}"
+
+ - job_name: blackbox-ssh
+ metrics_path: /probe
+ params:
+ module: [ssh_banner]
+
+ static_configs:
+ - targets:
+ - lovelace.box.pydis.wtf
+ - turing.box.pydis.wtf
+
+ relabel_configs:
+ # Ensure that the SSH port is included explicitly
+ - source_labels: [__address__]
+ regex: (.*?)(:.*)?
+ replacement: ${1}:22
+ target_label: __param_target
+
+ - source_labels: [__param_target]
+ target_label: instance
+
+ - target_label: __address__
+ replacement: localhost:9115
+
+ - job_name: blackbox-http
+ metrics_path: /probe
+ params:
+ module: [http_2xx]
+ static_configs:
+ - targets:
+ - https://pydis.wtf/
+ - https://cloud.native.is.fun.and.easy.pydis.wtf/
+ relabel_configs:
+ - source_labels: [__address__]
+ target_label: __param_target
+ - source_labels: [__param_target]
+ target_label: instance
+ - target_label: __address__
diff --git a/ansible/playbook.yml b/ansible/playbook.yml
index e963a31..ad8f2ad 100644
--- a/ansible/playbook.yml
+++ b/ansible/playbook.yml
@@ -14,6 +14,7 @@
hosts: lovelace
roles:
- prometheus
+ - prometheus-blackbox-exporter
- name: Deploy nginx & certbot to hosts
hosts: nginx
diff --git a/ansible/roles/prometheus-blackbox-exporter/README.md b/ansible/roles/prometheus-blackbox-exporter/README.md
new file mode 100644
index 0000000..d84e7ed
--- /dev/null
+++ b/ansible/roles/prometheus-blackbox-exporter/README.md
@@ -0,0 +1,3 @@
+# Role "prometheus-blackbox-exporter"
+
+Installs `prometheus-blackbox-exporter` on target hosts.
diff --git a/ansible/roles/prometheus-blackbox-exporter/tasks/main.yaml b/ansible/roles/prometheus-blackbox-exporter/tasks/main.yaml
new file mode 100644
index 0000000..bba364c
--- /dev/null
+++ b/ansible/roles/prometheus-blackbox-exporter/tasks/main.yaml
@@ -0,0 +1,7 @@
+---
+- name: Install prometheus-blackbox-exporter
+ package:
+ name: prometheus-blackbox-exporter
+ state: present
+ tags:
+ - role::prometheus-blackbox-exporter
diff --git a/ansible/roles/prometheus/defaults/main.yml b/ansible/roles/prometheus/defaults/main.yml
deleted file mode 100644
index fc2da50..0000000
--- a/ansible/roles/prometheus/defaults/main.yml
+++ /dev/null
@@ -1,47 +0,0 @@
----
-# Default Prometheus configuration sample
-prometheus_configuration:
- global:
- scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
- evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
- # scrape_timeout is set to the global default (10s).
-
- # Attach these labels to any time series or alerts when communicating with
- # external systems (federation, remote storage, Alertmanager).
- external_labels:
- monitor: 'example'
-
- # Alertmanager configuration
- alerting:
- alertmanagers:
- - static_configs:
- - targets: ['localhost:9093']
-
- # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
- rule_files:
- - "rules.yml"
-
- # A scrape configuration containing exactly one endpoint to scrape:
- # Here it's Prometheus itself.
- scrape_configs:
- # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- - job_name: 'prometheus'
-
- # Override the global default and scrape targets from this job every 5 seconds.
- scrape_interval: 5s
- scrape_timeout: 5s
-
- # metrics_path defaults to '/metrics'
- # scheme defaults to 'http'.
-
- static_configs:
- - targets: ['localhost:9090']
-
- - job_name: node
- # If prometheus-node-exporter is installed, grab stats about the local
- # machine by default.
- static_configs:
- - targets: ['localhost:9100']
-
-prometheus_rules:
- groups: []