lol

nixos/karma: init

+223
+7
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
··· 235 235 </listitem> 236 236 <listitem> 237 237 <para> 238 + <link xlink:href="https://github.com/prymitive/karma">karma</link>, 239 + an alert dashboard for Prometheus Alertmanager. Available as 240 + <link xlink:href="options.html#opt-services.karma.enable">services.karma</link> 241 + </para> 242 + </listitem> 243 + <listitem> 244 + <para> 238 245 <link xlink:href="https://languagetool.org/">languagetool</link>, 239 246 a multilingual grammar, style, and spell checker. Available as 240 247 <link xlink:href="options.html#opt-services.languagetool.enable">services.languagetool</link>.
+2
nixos/doc/manual/release-notes/rl-2211.section.md
··· 84 84 - [kanata](https://github.com/jtroo/kanata), a tool to improve keyboard comfort and usability with advanced customization. 85 85 Available as [services.kanata](options.html#opt-services.kanata.enable). 86 86 87 + - [karma](https://github.com/prymitive/karma), an alert dashboard for Prometheus Alertmanager. Available as [services.karma](options.html#opt-services.karma.enable) 88 + 87 89 - [languagetool](https://languagetool.org/), a multilingual grammar, style, and spell checker. 88 90 Available as [services.languagetool](options.html#opt-services.languagetool.enable). 89 91
+1
nixos/modules/module-list.nix
··· 682 682 ./services/monitoring/heapster.nix 683 683 ./services/monitoring/incron.nix 684 684 ./services/monitoring/kapacitor.nix 685 + ./services/monitoring/karma.nix 685 686 ./services/monitoring/kthxbye.nix 686 687 ./services/monitoring/loki.nix 687 688 ./services/monitoring/longview.nix
+128
nixos/modules/services/monitoring/karma.nix
··· 1 + { config, pkgs, lib, ... }: 2 + with lib; 3 + let 4 + cfg = config.services.karma; 5 + yaml = pkgs.formats.yaml { }; 6 + in 7 + { 8 + options.services.karma = { 9 + enable = mkEnableOption (mdDoc "the Karma dashboard service"); 10 + 11 + package = mkOption { 12 + type = types.package; 13 + default = pkgs.karma; 14 + defaultText = literalExpression "pkgs.karma"; 15 + description = mdDoc '' 16 + The Karma package that should be used. 17 + ''; 18 + }; 19 + 20 + configFile = mkOption { 21 + type = types.path; 22 + default = yaml.generate "karma.yaml" cfg.settings; 23 + defaultText = "A configuration file generated from the provided nix attributes settings option."; 24 + description = mdDoc '' 25 + A YAML config file which can be used to configure karma instead of the nix-generated file. 26 + ''; 27 + example = "/etc/karma/karma.conf"; 28 + }; 29 + 30 + environment = mkOption { 31 + type = with types; attrsOf str; 32 + default = {}; 33 + description = mdDoc '' 34 + Additional environment variables to provide to karma. 35 + ''; 36 + example = { 37 + ALERTMANAGER_URI = "https://alertmanager.example.com"; 38 + ALERTMANAGER_NAME= "single"; 39 + }; 40 + }; 41 + 42 + openFirewall = mkOption { 43 + type = types.bool; 44 + default = false; 45 + description = mdDoc '' 46 + Whether to open ports in the firewall needed for karma to function. 47 + ''; 48 + }; 49 + 50 + extraOptions = mkOption { 51 + type = with types; listOf str; 52 + default = []; 53 + description = mdDoc '' 54 + Extra command line options. 55 + ''; 56 + example = [ 57 + "--alertmanager.timeout 10s" 58 + ]; 59 + }; 60 + 61 + settings = mkOption { 62 + type = types.submodule { 63 + freeformType = yaml.type; 64 + 65 + options.listen = { 66 + address = mkOption { 67 + type = types.str; 68 + default = "127.0.0.1"; 69 + description = mdDoc '' 70 + Hostname or IP to listen on. 71 + ''; 72 + example = "[::]"; 73 + }; 74 + 75 + port = mkOption { 76 + type = types.port; 77 + default = 8080; 78 + description = mdDoc '' 79 + HTTP port to listen on. 80 + ''; 81 + example = 8182; 82 + }; 83 + }; 84 + }; 85 + default = { 86 + listen = { 87 + address = "127.0.0.1"; 88 + }; 89 + }; 90 + description = mdDoc '' 91 + Karma dashboard configuration as nix attributes. 92 + 93 + Reference: <https://github.com/prymitive/karma/blob/main/docs/CONFIGURATION.md> 94 + ''; 95 + example = { 96 + listen = { 97 + address = "192.168.1.4"; 98 + port = "8000"; 99 + prefix = "/dashboard"; 100 + }; 101 + alertmanager = { 102 + interval = "15s"; 103 + servers = [ 104 + { 105 + name = "prod"; 106 + uri = "http://alertmanager.example.com"; 107 + } 108 + ]; 109 + }; 110 + }; 111 + }; 112 + }; 113 + 114 + config = mkIf cfg.enable { 115 + systemd.services.karma = { 116 + description = "Alert dashboard for Prometheus Alertmanager"; 117 + wantedBy = [ "multi-user.target" ]; 118 + environment = cfg.environment; 119 + serviceConfig = { 120 + Type = "simple"; 121 + DynamicUser = true; 122 + Restart = "on-failure"; 123 + ExecStart = "${pkgs.karma}/bin/karma --config.file ${cfg.configFile} ${concatStringsSep " " cfg.extraOptions}"; 124 + }; 125 + }; 126 + networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.settings.listen.port ]; 127 + }; 128 + }
+1
nixos/tests/all-tests.nix
··· 299 299 k3s = handleTest ./k3s {}; 300 300 kafka = handleTest ./kafka.nix {}; 301 301 kanidm = handleTest ./kanidm.nix {}; 302 + karma = handleTest ./karma.nix {}; 302 303 kbd-setfont-decompress = handleTest ./kbd-setfont-decompress.nix {}; 303 304 kbd-update-search-paths-patch = handleTest ./kbd-update-search-paths-patch.nix {}; 304 305 kea = handleTest ./kea.nix {};
+84
nixos/tests/karma.nix
··· 1 + import ./make-test-python.nix ({ lib, pkgs, ... }: { 2 + name = "karma"; 3 + nodes = { 4 + server = { ... }: { 5 + services.prometheus.alertmanager = { 6 + enable = true; 7 + logLevel = "debug"; 8 + port = 9093; 9 + openFirewall = true; 10 + configuration = { 11 + global = { 12 + resolve_timeout = "1m"; 13 + }; 14 + route = { 15 + # Root route node 16 + receiver = "test"; 17 + group_by = ["..."]; 18 + continue = false; 19 + group_wait = "1s"; 20 + group_interval="15s"; 21 + repeat_interval = "24h"; 22 + }; 23 + receivers = [ 24 + { 25 + name = "test"; 26 + webhook_configs = [ 27 + { 28 + url = "http://localhost:1234"; 29 + send_resolved = true; 30 + max_alerts = 0; 31 + } 32 + ]; 33 + } 34 + ]; 35 + }; 36 + }; 37 + services.karma = { 38 + enable = true; 39 + openFirewall = true; 40 + settings = { 41 + listen = { 42 + address = "0.0.0.0"; 43 + port = 8081; 44 + }; 45 + alertmanager = { 46 + servers = [ 47 + { 48 + name = "alertmanager"; 49 + uri = "https://127.0.0.1:9093"; 50 + } 51 + ]; 52 + }; 53 + karma.name = "test-dashboard"; 54 + log.config = true; 55 + log.requests = true; 56 + log.timestamp = true; 57 + }; 58 + }; 59 + }; 60 + }; 61 + 62 + testScript = '' 63 + start_all() 64 + 65 + with subtest("Wait for server to come up"): 66 + 67 + server.wait_for_unit("alertmanager.service") 68 + server.wait_for_unit("karma.service") 69 + 70 + server.sleep(5) # wait for both services to settle 71 + 72 + server.wait_for_open_port(9093) 73 + server.wait_for_open_port(8081) 74 + 75 + with subtest("Test alertmanager readiness"): 76 + server.succeed("curl -s http://127.0.0.1:9093/-/ready") 77 + 78 + # Karma only starts serving the dashboard once it has established connectivity to all alertmanagers in its config 79 + # Therefore, this will fail if karma isn't able to reach alertmanager 80 + server.succeed("curl -s http://127.0.0.1:8081") 81 + 82 + server.shutdown() 83 + ''; 84 + })