summaryrefslogtreecommitdiff
path: root/modules/nixos/alertmanager.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2023-03-23 16:59:15 +0300
committerAzat Bahawi <azat@bahawi.net>2023-03-23 16:59:15 +0300
commitf6e36a699ae2d073e340e0a5844b8e111ed3de37 (patch)
tree52bb1d04e7b027165245b55622859b8425105fc7 /modules/nixos/alertmanager.nix
parenteb6eebde166112397e8711a16a8618a52ecbcaca (diff)
2023-03-23
Diffstat (limited to 'modules/nixos/alertmanager.nix')
-rw-r--r--modules/nixos/alertmanager.nix79
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";
+ };
};
}