1 { config, pkgs, lib, ... }:
5 cfg = config.services.kthxbye;
9 options.services.kthxbye = {
10 enable = mkEnableOption "kthxbye alert acknowledgement management daemon";
12 package = mkPackageOption pkgs "kthxbye" { };
14 openFirewall = mkOption {
18 Whether to open ports in the firewall needed for the daemon to function.
22 extraOptions = mkOption {
23 type = with types; listOf str;
26 Extra command line options.
28 Documentation can be found [here](https://github.com/prymitive/kthxbye/blob/main/README.md).
30 example = literalExpression ''
32 "-extend-with-prefix 'ACK!'"
42 Alertmanager request timeout duration in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
48 default = "http://localhost:9093";
50 Alertmanager URI to use.
52 example = "https://alertmanager.example.com";
60 Extend silences by adding DURATION seconds.
62 DURATION should be provided in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
67 extendIfExpiringIn = mkOption {
71 Extend silences that are about to expire in the next DURATION seconds.
73 DURATION should be provided in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
78 extendWithPrefix = mkOption {
82 Extend silences with comment starting with PREFIX string.
84 example = "!perma-silence";
91 Silence check interval duration in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
96 listenAddress = mkOption {
100 The address to listen on for HTTP requests.
102 example = "127.0.0.1";
109 The port to listen on for HTTP requests.
117 Format logged messages as JSON.
121 maxDuration = mkOption {
122 type = with types; nullOr str;
125 Maximum duration of a silence, it won't be extended anymore after reaching it.
127 Duration should be provided in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
133 config = mkIf cfg.enable {
134 systemd.services.kthxbye = {
135 description = "kthxbye Alertmanager ack management daemon";
136 wantedBy = [ "multi-user.target" ];
138 ${cfg.package}/bin/kthxbye \
139 -alertmanager.timeout ${cfg.alertmanager.timeout} \
140 -alertmanager.uri ${cfg.alertmanager.uri} \
141 -extend-by ${cfg.extendBy} \
142 -extend-if-expiring-in ${cfg.extendIfExpiringIn} \
143 -extend-with-prefix ${cfg.extendWithPrefix} \
144 -interval ${cfg.interval} \
145 -listen ${cfg.listenAddress}:${toString cfg.port} \
146 ${optionalString cfg.logJSON "-log-json"} \
147 ${optionalString (cfg.maxDuration != null) "-max-duration ${cfg.maxDuration}"} \
148 ${concatStringsSep " " cfg.extraOptions}
153 Restart = "on-failure";
157 networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];