1
0

hosts/monitoring-3: move to blackbox monitoring

This commit is contained in:
clerie 2022-10-31 22:54:06 +01:00
parent eefd8af665
commit be5b1c1baf
4 changed files with 117 additions and 24 deletions

View File

@ -123,6 +123,7 @@
enable = true; enable = true;
id = "101"; id = "101";
pubkey = "H9Pvx/BzwEMM7acT9mioT8zBD2Yn13L82EKKqdAfeGM="; pubkey = "H9Pvx/BzwEMM7acT9mioT8zBD2Yn13L82EKKqdAfeGM=";
blackbox = true;
}; };
system.stateVersion = "21.03"; system.stateVersion = "21.03";

View File

@ -29,6 +29,14 @@ let
attrByPath ["clerie" "monitoring" "bird"] false host.config) attrByPath ["clerie" "monitoring" "bird"] false host.config)
monitoringHosts); monitoringHosts);
blackboxMonitoringTargets = mapAttrsToList (name: host:
"${host.config.networking.hostName}.mon.clerie.de:9115")
(filterAttrs (name: host:
attrByPath ["clerie" "monitoring" "blackbox"] false host.config)
monitoringHosts);
eachWithEachOther = (f: x: y: lib.lists.flatten (lib.lists.forEach x (a: lib.lists.forEach y (b: f a b))));
in { in {
imports = imports =
[ [
@ -68,19 +76,6 @@ in {
networking.firewall.allowedUDPPorts = [ 54523 ]; networking.firewall.allowedUDPPorts = [ 54523 ];
services.prometheus.exporters.node.enable = true; services.prometheus.exporters.node.enable = true;
services.prometheus.exporters.smokeping = {
enable = true;
listenAddress = "[::1]";
port = 9374;
hosts = [
"clerie.de"
"fluorine.net.clerie.de"
"www.fem.tu-ilmenau.de"
"www.heise.de"
"212.218.154.100" # ie10-ffm1
"matrix.bau-ha.us"
];
};
services.prometheus.xmpp-alerts = { services.prometheus.xmpp-alerts = {
enable = true; enable = true;
@ -163,6 +158,93 @@ in {
} }
]; ];
} }
{
job_name = "blackbox_icmp6";
scrape_interval = "20s";
metrics_path = "/probe";
params = {
module = [ "icmp6" ];
};
static_configs = [
{
targets = eachWithEachOther (instance: target: "${instance};${target}") blackboxMonitoringTargets [
"clerie.de"
"tagesschau.de"
"google.com"
"achtbaan.nikhef.nl"
"fluorine.net.clerie.de"
"www.fem.tu-ilmenau.de"
"www.heise.de"
];
}
];
relabel_configs = [
{
source_labels = [ "__address__" ];
regex = "(.+);(.+)";
target_label = "__param_target";
replacement = "\${2}";
}
{
source_labels = [ "__param_target" ];
target_label = "target";
}
{
source_labels = [ "__address__" ];
regex = "(.+);(.+)";
target_label = "__address__";
replacement = "\${1}";
}
{
source_labels = [ "__address__" ];
target_label = "instance";
}
];
}
{
job_name = "blackbox_icmp4";
scrape_interval = "20s";
metrics_path = "/probe";
params = {
module = [ "icmp4" ];
};
static_configs = [
{
targets = eachWithEachOther (instance: target: "${instance};${target}") blackboxMonitoringTargets [
"clerie.de"
"tagesschau.de"
"google.com"
"achtbaan.nikhef.nl"
"www.fem.tu-ilmenau.de"
"www.heise.de"
"ie10-ffm2.nodes.nethinks.com"
"matrix.bau-ha.us"
];
}
];
relabel_configs = [
{
source_labels = [ "__address__" ];
regex = "(.+);(.+)";
target_label = "__param_target";
replacement = "\${2}";
}
{
source_labels = [ "__param_target" ];
target_label = "target";
}
{
source_labels = [ "__address__" ];
regex = "(.+);(.+)";
target_label = "__address__";
replacement = "\${1}";
}
{
source_labels = [ "__address__" ];
target_label = "instance";
}
];
}
{ {
job_name = "zimmer-temp"; job_name = "zimmer-temp";
scrape_interval = "20s"; scrape_interval = "20s";
@ -200,17 +282,6 @@ in {
} }
]; ];
} }
{
job_name = "smokeping";
scrape_interval = "20s";
static_configs = [
{
targets = [
"monitoring-3.mon.clerie.de:9374"
];
}
];
}
]; ];
alertmanagers = [ alertmanagers = [
{ {

View File

@ -58,6 +58,7 @@
enable = true; enable = true;
id = "102"; id = "102";
pubkey = "+mJN+ustPo2ehP0wqajYs3nTdJ0SPuIDyiZQSHFIK3o="; pubkey = "+mJN+ustPo2ehP0wqajYs3nTdJ0SPuIDyiZQSHFIK3o=";
blackbox = true;
}; };
system.stateVersion = "21.03"; system.stateVersion = "21.03";

View File

@ -22,6 +22,7 @@ in
description = "Public Key of the monitoring wireguard interface of this host"; description = "Public Key of the monitoring wireguard interface of this host";
}; };
bird = mkEnableOption "Monitor bird"; bird = mkEnableOption "Monitor bird";
blackbox = mkEnableOption "Monitor blackbox";
}; };
}; };
@ -54,5 +55,24 @@ in
openFirewall = true; openFirewall = true;
firewallFilter = "-i wg-monitoring -p tcp -m tcp --dport 9324"; firewallFilter = "-i wg-monitoring -p tcp -m tcp --dport 9324";
}; };
services.prometheus.exporters.blackbox = mkIf cfg.blackbox {
enable = true;
openFirewall = true;
firewallFilter = "-i wg-monitoring -p tcp -m tcp --dport 9115";
configFile = pkgs.writeText "blackbox.yml" ''
modules:
icmp6:
prober: icmp
icmp:
preferred_ip_protocol: ip6
ip_protocol_fallback: false
icmp4:
prober: icmp
icmp:
preferred_ip_protocol: ip4
ip_protocol_fallback: false
'';
};
}; };
} }