diff options
Diffstat (limited to 'modules/alertmanager.nix')
-rw-r--r-- | modules/alertmanager.nix | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/modules/alertmanager.nix b/modules/alertmanager.nix deleted file mode 100644 index 94c21b0..0000000 --- a/modules/alertmanager.nix +++ /dev/null @@ -1,95 +0,0 @@ -{ - config, - inputs, - lib, - libNginx, - this, - ... -}: -let - cfg = config.nixfiles.modules.alertmanager; -in -{ - imports = [ inputs.alertmanager-ntfy.nixosModules.default ]; - - options.nixfiles.modules.alertmanager = { - enable = lib.mkEnableOption "Alertmanager"; - - port = lib.mkOption { - description = "Port."; - type = lib.types.port; - default = 30112; - }; - - domain = lib.mkOption { - description = "Domain name sans protocol scheme."; - type = with lib.types; nullOr str; - default = "alertmanager.${config.networking.domain}"; - }; - }; - - config = lib.mkIf cfg.enable { - nixfiles.modules = { - ntfy.enable = true; - nginx = { - enable = true; - upstreams.alertmanager.servers."127.0.0.1:${toString cfg.port}" = { }; - virtualHosts.${cfg.domain} = { - locations."/".proxyPass = "http://alertmanager"; - extraConfig = libNginx.config.internalOnly; - }; - }; - }; - - services = { - prometheus.alertmanager = { - enable = true; - - listenAddress = "127.0.0.1"; - inherit (cfg) port; - - extraFlags = [ - "--cluster.listen-address=\"\"" - "--web.external-url=https://${cfg.domain}" - ]; - - configuration = { - global = { - smtp_from = "alertmanager@${lib.my.domain.shire}"; - smtp_smarthost = "${lib.my.domain.shire}:584"; - }; - - route = { - receiver = lib.my.username; - group_by = [ "alertname" ]; - }; - - receivers = [ - { - name = lib.my.username; - webhook_configs = [ - { url = with config.services.alertmanager-ntfy; "http://${httpAddress}:${httpPort}"; } - ]; - } - ]; - }; - }; - }; - - 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"; - }; - - topology.nodes.${this.hostname}.services.alertmanager = { - name = "Alertmanager"; - icon = "${inputs.homelab-svg-assets}/assets/prometheus.svg"; - info = cfg.domain; - details.listen.text = "127.0.0.1:${toString cfg.port}"; - }; - }; -} |