yep, more dotfiles

feat(server): add grafana and prometheus instance

+38 -2
+38 -2
nixos/profiles/server.nix
··· 25 25 26 26 tangled-port = 3002; 27 27 tangled-hostname = "knot.wiro.world"; 28 + 29 + grafana-port = 9000; 30 + grafana-hostname = "console.wiro.world"; 31 + prometheus-port = 9001; 32 + prometheus-node-exporter-port = 9002; 28 33 in 29 34 { 30 35 imports = [ ··· 102 107 103 108 services.caddy = { 104 109 enable = true; 110 + package = upkgs.caddy; 105 111 106 112 globalConfig = '' 113 + metrics { per_host } 114 + 107 115 on_demand_tls { 108 116 ask http://localhost:${toString pds-port}/tls-check 109 117 } 110 118 ''; 111 119 112 - virtualHosts."ping.wiro.world".extraConfig = '' 113 - respond "Hello, World! (from `weird-row-server`)" 120 + # Grafana has its own auth 121 + virtualHosts.${grafana-hostname}.extraConfig = '' 122 + reverse_proxy http://localhost:${toString grafana-port} 114 123 ''; 115 124 116 125 virtualHosts.${pds-hostname} = { ··· 139 148 listenAddr = "0.0.0.0:${toString tangled-port}"; 140 149 secretFile = config.age.secrets.tangled-config.path; 141 150 hostname = tangled-hostname; 151 + }; 152 + }; 153 + 154 + services.grafana = { 155 + enable = true; 156 + 157 + settings.server.http_port = grafana-port; 158 + }; 159 + 160 + services.prometheus = { 161 + enable = true; 162 + port = prometheus-port; 163 + 164 + scrapeConfigs = [ 165 + { 166 + job_name = "caddy"; 167 + static_configs = [{ targets = [ "localhost:${toString 2019}" ]; }]; 168 + } 169 + { 170 + job_name = "node"; 171 + static_configs = [{ targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; }]; 172 + } 173 + ]; 174 + 175 + exporters.node = { 176 + enable = true; 177 + port = prometheus-node-exporter-port; 142 178 }; 143 179 }; 144 180 };