profiles/monitoring-server: Fetch monitoring targets from json file
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
./grafana.nix
|
./grafana.nix
|
||||||
./nixos-validator.nix
|
./nixos-validator.nix
|
||||||
./prometheus.nix
|
./prometheus.nix
|
||||||
|
./targets.nix
|
||||||
./uptimestatus.nix
|
./uptimestatus.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -141,10 +141,7 @@ in {
|
|||||||
};
|
};
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{
|
{
|
||||||
targets = [
|
targets = map (target: "${target};infra") config.profiles.clerie.monitoring-server.probeTargets.node-exporter-uberspace;
|
||||||
"clerie.uber.space;infra"
|
|
||||||
"cleriewi.uber.space;infra"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
relabel_configs = [
|
relabel_configs = [
|
||||||
@@ -225,17 +222,7 @@ in {
|
|||||||
};
|
};
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{
|
{
|
||||||
targets = eachWithEachOther (instance: target: "${instance};${target}") blackboxMonitoringTargets [
|
targets = eachWithEachOther (instance: target: "${instance};${target}") blackboxMonitoringTargets config.profiles.clerie.monitoring-server.probeTargets.blackbox-icmp6;
|
||||||
"clerie.de"
|
|
||||||
"tagesschau.de"
|
|
||||||
"google.com"
|
|
||||||
"achtbaan.nikhef.nl"
|
|
||||||
"fluorine.net.clerie.de"
|
|
||||||
"www.fem.tu-ilmenau.de"
|
|
||||||
"www.heise.de"
|
|
||||||
"dyon.net.entr0py.de"
|
|
||||||
"matrix.fachschaften.org"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
relabel_configs = [
|
relabel_configs = [
|
||||||
@@ -267,18 +254,7 @@ in {
|
|||||||
};
|
};
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{
|
{
|
||||||
targets = eachWithEachOther (instance: target: "${instance};${target}") blackboxMonitoringTargets [
|
targets = eachWithEachOther (instance: target: "${instance};${target}") blackboxMonitoringTargets config.profiles.clerie.monitoring-server.probeTargets.blackbox-icmp4;
|
||||||
"clerie.de"
|
|
||||||
"tagesschau.de"
|
|
||||||
"google.com"
|
|
||||||
"achtbaan.nikhef.nl"
|
|
||||||
"www.fem.tu-ilmenau.de"
|
|
||||||
"www.heise.de"
|
|
||||||
"matrix.bau-ha.us"
|
|
||||||
"dyon.net.entr0py.de"
|
|
||||||
"matrix.entr0py.de"
|
|
||||||
"matrix.fachschaften.org"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
relabel_configs = [
|
relabel_configs = [
|
||||||
@@ -310,10 +286,7 @@ in {
|
|||||||
};
|
};
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{
|
{
|
||||||
targets = [
|
targets = config.profiles.clerie.monitoring-server.probeTargets.blackbox-local-synapse;
|
||||||
"matrix.entr0py.de"
|
|
||||||
"matrix.fachschaften.org"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
relabel_configs = [
|
relabel_configs = [
|
||||||
|
7
hosts/monitoring-3/targets.nix
Normal file
7
hosts/monitoring-3/targets.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
profiles.clerie.monitoring-server.targets = builtins.fromJSON (builtins.readFile ../../monitoring/targets.json);
|
||||||
|
|
||||||
|
}
|
46
monitoring/targets.json
Normal file
46
monitoring/targets.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"clerie.de": {
|
||||||
|
"icmp": { "enable": true },
|
||||||
|
"http": { "enable": true }
|
||||||
|
},
|
||||||
|
"tagesschau.de": {
|
||||||
|
"icmp": { "enable": true }
|
||||||
|
},
|
||||||
|
"google.com": {
|
||||||
|
"icmp": { "enable": true }
|
||||||
|
},
|
||||||
|
"achtbaan.nikhef.nl": {
|
||||||
|
"icmp": { "enable": true }
|
||||||
|
},
|
||||||
|
"www.fem.tu-ilmenau.de": {
|
||||||
|
"icmp": { "enable": true }
|
||||||
|
},
|
||||||
|
"www.heise.de": {
|
||||||
|
"icmp": { "enable": true }
|
||||||
|
},
|
||||||
|
"dyon.net.entr0py.de": {
|
||||||
|
"_comment": "Backend server of matrix.entr0py.de",
|
||||||
|
"icmp": { "enable": true }
|
||||||
|
},
|
||||||
|
"matrix.bau-ha.us": {
|
||||||
|
"icmp": {
|
||||||
|
"enable": true,
|
||||||
|
"protocols": [ "ipv4" ]
|
||||||
|
},
|
||||||
|
"synapse": { "enable": true }
|
||||||
|
},
|
||||||
|
"matrix.entr0py.de": {
|
||||||
|
"icmp": { "enable": true },
|
||||||
|
"synapse": { "enable": true }
|
||||||
|
},
|
||||||
|
"matrix.fachschaften.org": {
|
||||||
|
"icmp": { "enable": true },
|
||||||
|
"synapse": { "enable": true }
|
||||||
|
},
|
||||||
|
"clerie.uber.space": {
|
||||||
|
"clerie-uberspace": { "enable": true }
|
||||||
|
},
|
||||||
|
"cleriewi.uber.space": {
|
||||||
|
"clerie-uberspace": { "enable": true }
|
||||||
|
}
|
||||||
|
}
|
@@ -14,6 +14,7 @@
|
|||||||
./hetzner-cloud
|
./hetzner-cloud
|
||||||
./hydra-build-machine
|
./hydra-build-machine
|
||||||
./mercury-vm
|
./mercury-vm
|
||||||
|
./monitoring-server
|
||||||
./netcup
|
./netcup
|
||||||
./network-fallback-dhcp
|
./network-fallback-dhcp
|
||||||
./router
|
./router
|
||||||
|
91
profiles/monitoring-server/default.nix
Normal file
91
profiles/monitoring-server/default.nix
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
mkAttrsOfSubmoduleOption = description: submoduleOptions: mkOption {
|
||||||
|
type = with types; attrsOf (submodule { options = submoduleOptions; });
|
||||||
|
default = {};
|
||||||
|
description = description;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkSubmoduleOption = description: submoduleOptions: mkOption {
|
||||||
|
type = types.submodule { options = submoduleOptions; };
|
||||||
|
default = {};
|
||||||
|
description = description;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkProbeOption = description: submoduleOptions: mkSubmoduleOption description ({
|
||||||
|
enable = mkEnableOption "Monitor target using this probe";
|
||||||
|
} // submoduleOptions);
|
||||||
|
|
||||||
|
mkProtocolsOption = mkOption {
|
||||||
|
type = with types; listOf (enum [ "ipv6" "ipv4" ]);
|
||||||
|
default = [ "ipv6" "ipv4" ];
|
||||||
|
description = "Protocols to retrieve metrics for";
|
||||||
|
};
|
||||||
|
|
||||||
|
mkTargetsListOption = mkOption {
|
||||||
|
type = with types; listOf str;
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
listContains = searchValue: listToSearch: any (element: element == searchValue) listToSearch;
|
||||||
|
|
||||||
|
targetsForProbe = probeName: condition: attrNames (filterAttrs (targetName: targetConfig:
|
||||||
|
targetConfig.${probeName}.enable == true && (condition targetConfig.${probeName})
|
||||||
|
) config.profiles.clerie.monitoring-server.targets);
|
||||||
|
|
||||||
|
in {
|
||||||
|
|
||||||
|
options.profiles.clerie.monitoring-server = {
|
||||||
|
targets = mkAttrsOfSubmoduleOption "Monitoring targets config" {
|
||||||
|
_comment = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
|
clerie-uberspace = mkProbeOption "This target is a uberspace host managed by clerie" {};
|
||||||
|
http = mkProbeOption "Monitor HTTP" {
|
||||||
|
protocols = mkProtocolsOption;
|
||||||
|
};
|
||||||
|
icmp = mkProbeOption "Monitor HTTP" {
|
||||||
|
protocols = mkProtocolsOption;
|
||||||
|
};
|
||||||
|
synapse = mkProbeOption "Monitor Synapse Matrix server" {};
|
||||||
|
};
|
||||||
|
|
||||||
|
probeTargets = mkSubmoduleOption "Target per probe" {
|
||||||
|
blackbox-http4 = mkTargetsListOption;
|
||||||
|
blackbox-http6 = mkTargetsListOption;
|
||||||
|
blackbox-icmp4 = mkTargetsListOption;
|
||||||
|
blackbox-icmp6 = mkTargetsListOption;
|
||||||
|
node-exporter-uberspace = mkTargetsListOption;
|
||||||
|
blackbox-local-synapse = mkTargetsListOption;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
|
||||||
|
profiles.clerie.monitoring-server.probeTargets.blackbox-http4 = targetsForProbe "http" (probeConfig:
|
||||||
|
(listContains "ipv4" probeConfig.protocols)
|
||||||
|
);
|
||||||
|
|
||||||
|
profiles.clerie.monitoring-server.probeTargets.blackbox-http6 = targetsForProbe "http" (probeConfig:
|
||||||
|
(listContains "ipv6" probeConfig.protocols)
|
||||||
|
);
|
||||||
|
|
||||||
|
profiles.clerie.monitoring-server.probeTargets.blackbox-icmp4 = targetsForProbe "icmp" (probeConfig:
|
||||||
|
(listContains "ipv4" probeConfig.protocols)
|
||||||
|
);
|
||||||
|
|
||||||
|
profiles.clerie.monitoring-server.probeTargets.blackbox-icmp6 = targetsForProbe "icmp" (probeConfig:
|
||||||
|
(listContains "ipv6" probeConfig.protocols)
|
||||||
|
);
|
||||||
|
|
||||||
|
profiles.clerie.monitoring-server.probeTargets.node-exporter-uberspace = targetsForProbe "clerie-uberspace" (_: true);
|
||||||
|
|
||||||
|
profiles.clerie.monitoring-server.probeTargets.blackbox-local-synapse = targetsForProbe "synapse" (_: true);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user