feat: enhance Blackbox Exporter configuration with domain blacklist and update Grafana alerting rules
This commit is contained in:
@@ -5,13 +5,32 @@ with lib;
|
|||||||
let
|
let
|
||||||
hostname = config.networking.hostName;
|
hostname = config.networking.hostName;
|
||||||
|
|
||||||
|
cfg = config.services.blackbox-exporter;
|
||||||
nginxVHosts = config.services.nginx.virtualHosts or {};
|
nginxVHosts = config.services.nginx.virtualHosts or {};
|
||||||
allDomains = lib.attrNames nginxVHosts;
|
allDomains = lib.attrNames nginxVHosts;
|
||||||
httpsDomains = lib.map (d: "https://${d}") allDomains;
|
filteredDomains = builtins.filter (d: !builtins.elem d cfg.blacklistDomains) allDomains;
|
||||||
|
httpsDomains = lib.map (d: "https://${d}") filteredDomains;
|
||||||
domainsString = builtins.concatStringsSep "\n "
|
domainsString = builtins.concatStringsSep "\n "
|
||||||
(map (d: "\"${d}\",") httpsDomains);
|
(map (d: "\"${d}\",") httpsDomains);
|
||||||
in {
|
in {
|
||||||
|
options.services.blackbox-exporter.blacklistDomains = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
description = "List of domains to monitor with Blackbox Exporter";
|
||||||
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
services.blackbox-exporter = {
|
||||||
|
blacklistDomains = [
|
||||||
|
"autoconfig.cloonar.com"
|
||||||
|
"cloonar.dev"
|
||||||
|
"loki.cloonar.com"
|
||||||
|
"stage.korean-skin.care"
|
||||||
|
"victoria-server.cloonar.com"
|
||||||
|
"updns.cloonar.com"
|
||||||
|
"feeds.jordanrannells.com"
|
||||||
|
];
|
||||||
|
};
|
||||||
# Systemd service for Blackbox Exporter
|
# Systemd service for Blackbox Exporter
|
||||||
systemd.services.blackbox-exporter = {
|
systemd.services.blackbox-exporter = {
|
||||||
description = "Blackbox Exporter";
|
description = "Blackbox Exporter";
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
cfg = config.services.blackbox-exporter;
|
||||||
nginxVHosts = config.services.nginx.virtualHosts or {};
|
nginxVHosts = config.services.nginx.virtualHosts or {};
|
||||||
allDomains = lib.attrNames nginxVHosts;
|
allDomains = lib.attrNames nginxVHosts;
|
||||||
httpsDomains = lib.map (d: "https://${d}") allDomains;
|
filteredDomains = builtins.filter (d: !builtins.elem d cfg.blacklistDomains) allDomains;
|
||||||
|
httpsDomains = lib.map (d: "https://${d}") filteredDomains;
|
||||||
websiteAlertRules = lib.map (target:
|
websiteAlertRules = lib.map (target:
|
||||||
let
|
let
|
||||||
domain = lib.replaceStrings ["://" "." "-" "/" ] ["-" "-" "_" "_"] target + "-down-alert";
|
domain = lib.replaceStrings ["://" "." "-" "/" ] ["-" "-" "_" "_"] target + "-down-alert";
|
||||||
|
|||||||
@@ -67,9 +67,7 @@ in
|
|||||||
use_pkce = true;
|
use_pkce = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
"auth.anonymous".enabled = true;
|
"auth.anonymous".enabled = false;
|
||||||
"auth.anonymous".org_name = "Cloonar e.U.";
|
|
||||||
"auth.anonymous".org_role = "Viewer";
|
|
||||||
|
|
||||||
server = {
|
server = {
|
||||||
root_url = "https://grafana.cloonar.com";
|
root_url = "https://grafana.cloonar.com";
|
||||||
|
|||||||
@@ -27,10 +27,4 @@ in
|
|||||||
proxyPass = "http://localhost:1323/";
|
proxyPass = "http://localhost:1323/";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services.nginx.virtualHosts."autoconfig.superbros.tv".extraConfig = ''
|
|
||||||
return 301 https://autoconfig.cloonar.com$request_uri;
|
|
||||||
'';
|
|
||||||
services.nginx.virtualHosts."autoconfig.korean-skin.care".extraConfig = ''
|
|
||||||
return 301 https://autoconfig.cloonar.com$request_uri;
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
{ pkgs, lib, config, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
let
|
let
|
||||||
domains = [
|
|
||||||
"cloonar.com"
|
|
||||||
"ghetto.at"
|
|
||||||
"optiprot.eu"
|
|
||||||
];
|
|
||||||
|
|
||||||
vhostConfig = {
|
vhostConfig = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
@@ -48,10 +42,6 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.nginx.virtualHosts."autoconfig.cloonar.com" = vhostConfig;
|
services.nginx.virtualHosts."autoconfig.cloonar.com" = vhostConfig;
|
||||||
services.nginx.virtualHosts."autoconfig.ghetto.at" = vhostConfig;
|
|
||||||
services.nginx.virtualHosts."autoconfig.optiprot.eu" = vhostConfig;
|
|
||||||
services.nginx.virtualHosts."autoconfig.superbros.tv" = vhostConfig;
|
|
||||||
services.nginx.virtualHosts."autoconfig.korean-skin.care" = vhostConfig;
|
|
||||||
|
|
||||||
systemd.services."phpfpm-autoconfig".serviceConfig.ProtectHome = lib.mkForce false;
|
systemd.services."phpfpm-autoconfig".serviceConfig.ProtectHome = lib.mkForce false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user