{
  config,
  pkgs,
  ...
}: {
  services.prometheus.alertmanagers = [
    {
      scheme = "http";
      # path_prefix = "/alertmanager";
      static_configs = [
        {
          targets = [
            "localhost:9093"
          ];
        }
      ];
    }
  ];
  services.prometheus.alertmanager = {
    enable = true;
    openFirewall = true;
    webExternalUrl = "http://monitor.lab:9093"; # optional but helpful
    configuration = {
      route = {
        group_wait = "10s";
        group_interval = "30s";
        repeat_interval = "30m";
        receiver = "telegram";

        routes = [
          {
            receiver = "telegram";
            group_wait = "10s";
            match_re = {
              severity = "critical|warning";
            };
            continue = true;
          }
        ];
      };

      receivers = [
        {
          name = "telegram";
          telegram_configs = [
            {
              api_url = "https://api.telegram.org";
              # FIX ME!
              bot_token = "7597031094:AAHjjo3HL1XdY38pSNlR66-4wCP47o4LlSw"; # config.sops.secrets."telegram-alert-bot-token".path;
              chat_id = -1002642560007;
              message_thread_id = 4;
              parse_mode = "HTML";
              send_resolved = true;
              message = "{{ template \"telegram.message\". }}";
            }
          ];
        }
      ];

      templates = [
        (pkgs.writeText "telegram.tmpl" (builtins.readFile ./provisioning/templates/telegram.tmpl))
        (pkgs.writeText "telegram.markdown.v2.tmpl" (builtins.readFile ./provisioning/templates/telegram.markdown.v2.tmpl))
      ];
    };
  };
}
