at 21.11-pre 2.9 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.trickster; 7in 8{ 9 10 options = { 11 services.trickster = { 12 enable = mkOption { 13 type = types.bool; 14 default = false; 15 description = '' 16 Enable Trickster. 17 ''; 18 }; 19 20 package = mkOption { 21 type = types.package; 22 default = pkgs.trickster; 23 defaultText = "pkgs.trickster"; 24 description = '' 25 Package that should be used for trickster. 26 ''; 27 }; 28 29 configFile = mkOption { 30 type = types.nullOr types.path; 31 default = null; 32 description = '' 33 Path to configuration file. 34 ''; 35 }; 36 37 instance-id = mkOption { 38 type = types.nullOr types.int; 39 default = null; 40 description = '' 41 Instance ID for when running multiple processes (default null). 42 ''; 43 }; 44 45 log-level = mkOption { 46 type = types.str; 47 default = "info"; 48 description = '' 49 Level of Logging to use (debug, info, warn, error) (default "info"). 50 ''; 51 }; 52 53 metrics-port = mkOption { 54 type = types.port; 55 default = 8082; 56 description = '' 57 Port that the /metrics endpoint will listen on. 58 ''; 59 }; 60 61 origin = mkOption { 62 type = types.str; 63 default = "http://prometheus:9090"; 64 description = '' 65 URL to the Prometheus Origin. Enter it like you would in grafana, e.g., http://prometheus:9090 (default http://prometheus:9090). 66 ''; 67 }; 68 69 profiler-port = mkOption { 70 type = types.nullOr types.port; 71 default = null; 72 description = '' 73 Port that the /debug/pprof endpoint will listen on. 74 ''; 75 }; 76 77 proxy-port = mkOption { 78 type = types.port; 79 default = 9090; 80 description = '' 81 Port that the Proxy server will listen on. 82 ''; 83 }; 84 85 }; 86 }; 87 88 config = mkIf cfg.enable { 89 systemd.services.trickster = { 90 description = "Dashboard Accelerator for Prometheus"; 91 after = [ "network.target" ]; 92 wantedBy = [ "multi-user.target" ]; 93 serviceConfig = { 94 DynamicUser = true; 95 ExecStart = '' 96 ${cfg.package}/bin/trickster \ 97 -log-level ${cfg.log-level} \ 98 -metrics-port ${toString cfg.metrics-port} \ 99 -origin ${cfg.origin} \ 100 -proxy-port ${toString cfg.proxy-port} \ 101 ${optionalString (cfg.configFile != null) "-config ${cfg.configFile}"} \ 102 ${optionalString (cfg.profiler-port != null) "-profiler-port ${cfg.profiler-port}"} \ 103 ${optionalString (cfg.instance-id != null) "-instance-id ${cfg.instance-id}"} 104 ''; 105 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 106 Restart = "always"; 107 }; 108 }; 109 }; 110 111 meta.maintainers = with maintainers; [ _1000101 ]; 112 113}