about summary refs log tree commit diff
path: root/hosts/common
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-04-04 11:30:22 -0700
committerFranck Cuny <franck@fcuny.net>2022-04-04 11:30:22 -0700
commitdf562434d327c0a7e1be35089642ae669f40e1de (patch)
treef6780acba24cd0b2c876f7e33eb2ac2746fe86d5 /hosts/common
parentdashboard: more update for traefik (diff)
downloadworld-df562434d327c0a7e1be35089642ae669f40e1de.tar.gz
prometheus: attempt to configure blackbox exporter
Diffstat (limited to 'hosts/common')
-rw-r--r--hosts/common/server/prometheus.nix34
1 files changed, 34 insertions, 0 deletions
diff --git a/hosts/common/server/prometheus.nix b/hosts/common/server/prometheus.nix
index 6ae25cf..bf6cb54 100644
--- a/hosts/common/server/prometheus.nix
+++ b/hosts/common/server/prometheus.nix
@@ -1,6 +1,23 @@
 { config, pkgs, lib, ... }:
 
 let
+  blackboxConfig = {
+    modules = {
+      https_2xx = {
+        prober = "http";
+        timeout = "5s";
+        http = {
+          method = "GET";
+          valid_status_codes = [ ];
+          fail_if_not_ssl = true;
+        };
+      };
+      icmp = {
+        prober = "icmp";
+        timeout = "5s";
+      };
+    };
+  };
   relabelConfigs = [
     {
       source_labels = [ "__address__" ];
@@ -25,6 +42,13 @@ let
     }
   ];
 in {
+  services.prometheus.exporters.blackbox = {
+    enable = true;
+    listenAddress = "127.0.0.1";
+    port = 9115;
+    configFile = pkgs.writeText "blackbox.yml" (builtins.toJSON blackboxConfig);
+  };
+
   services.prometheus = {
     enable = true;
 
@@ -36,6 +60,16 @@ in {
       "--web.enable-admin-api"
     ];
 
+    blackboxTargets = [{
+      job_name = "icmp_probe";
+      metrics_path = "/probe/blackbox";
+      scrape_interval = "1m";
+      params = { module = [ "icmp" ]; };
+      targets = [ "8.8.8.8" ];
+      static_configs = [{ targets = [ "127.0.0.1:9115" ]; }];
+      relabel_configs = relabelConfigs;
+    }];
+
     scrapeConfigs = [
       {
         job_name = "node";