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