diff options
Diffstat (limited to '')
-rw-r--r-- | modules/nixos/alertmanager.nix | 79 |
1 files changed, 53 insertions, 26 deletions
diff --git a/modules/nixos/alertmanager.nix b/modules/nixos/alertmanager.nix index 871b0c4..8f5b34b 100644 --- a/modules/nixos/alertmanager.nix +++ b/modules/nixos/alertmanager.nix @@ -1,11 +1,14 @@ { config, + inputs, lib, ... }: with lib; let cfg = config.nixfiles.modules.alertmanager; in { + imports = [inputs.alertmanager-ntfy.nixosModules.default]; + options.nixfiles.modules.alertmanager = { enable = mkEnableOption "Alertmanager"; @@ -23,41 +26,65 @@ in { }; config = mkIf cfg.enable { - nixfiles.modules.nginx = with cfg; { - enable = true; - upstreams.alertmanager.servers."127.0.0.1:${toString cfg.port}" = {}; - virtualHosts.${cfg.domain} = { - locations."/".proxyPass = "http://alertmanager"; - extraConfig = nginxInternalOnly; + nixfiles.modules = { + ntfy.enable = true; + nginx = with cfg; { + enable = true; + upstreams.alertmanager.servers."127.0.0.1:${toString cfg.port}" = {}; + virtualHosts.${cfg.domain} = { + locations."/".proxyPass = "http://alertmanager"; + extraConfig = nginxInternalOnly; + }; }; }; - services.prometheus.alertmanager = { - enable = true; + services = { + prometheus.alertmanager = { + enable = true; - listenAddress = "127.0.0.1"; - inherit (cfg) port; + listenAddress = "127.0.0.1"; + inherit (cfg) port; - extraFlags = ["--web.external-url=https://${cfg.domain}"]; + extraFlags = ["--web.external-url=https://${cfg.domain}"]; - configuration = { - global = { - smtp_from = "alertmanager@${my.domain.shire}"; - smtp_smarthost = "${my.domain.shire}:584"; - }; + configuration = { + global = { + smtp_from = "alertmanager@${my.domain.shire}"; + smtp_smarthost = "${my.domain.shire}:584"; + }; - route = { - receiver = my.username; - group_by = ["alertname"]; - }; + route = { + receiver = my.username; + group_by = ["alertname"]; + }; - receivers = [ - { - name = my.username; - email_configs = [{to = "${my.username}+alert@${my.domain.shire}";}]; - } - ]; + receivers = [ + { + name = my.username; + # TODO + # email_configs = [ + # { + # to = "${my.username}+alert@${my.domain.shire}"; + # } + # ]; + webhook_configs = [ + { + url = with config.pinpox.services.alertmanager-ntfy; "http://${httpAddress}:${httpPort}"; + } + ]; + } + ]; + }; }; }; + + pinpox.services.alertmanager-ntfy = { + enable = true; + httpAddress = "127.0.0.1"; + httpPort = toString (config.nixfiles.modules.ntfy.port + 1); + ntfyTopic = "${config.services.ntfy-sh.settings.base-url}/alertmanager"; + ntfyPriority = "high"; + envFile = "/dev/null"; + }; }; } |