diff options
author | stuebinm | 2022-11-11 23:19:34 +0100 |
---|---|---|
committer | stuebinm | 2022-11-11 23:19:34 +0100 |
commit | bf87b3460ac23d77f2585d247292f40616f59c4b (patch) | |
tree | ab04c05b9901466bb2127d2788d722f52ad27327 /chaski/services | |
parent | ff73944329c4152a293550559609ded1f452abfb (diff) |
chaski/tracktrain: add a grafana
Diffstat (limited to 'chaski/services')
-rw-r--r-- | chaski/services/tracktrain.nix | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/chaski/services/tracktrain.nix b/chaski/services/tracktrain.nix index 3d59806..5887f73 100644 --- a/chaski/services/tracktrain.nix +++ b/chaski/services/tracktrain.nix @@ -19,12 +19,62 @@ in proxyPass = "http://192.168.42.41:4000"; proxyWebsockets = true; }; + # don't expose prometheus endpoint + locations."/metrics".return = "404"; + enableACME = true; forceSSL = true; extraConfig = '' add_header 'Access-Control-Allow-Origin' '*' always; ''; }; + services.nginx.virtualHosts."tracktrain.ilztalbahn.eu" = { + locations."/api" = { + proxyPass = "http://192.168.42.41:4000"; + proxyWebsockets = true; + extraConfig = '' + add_header 'Access-Control-Allow-Origin' '*' always; + ''; + }; + locations."/metrics/" = { + proxyPass = "http://localhost:2342"; + proxyWebsockets = true; + extraConfig = '' + rewrite ^/metrics/(.*) /$1 break; + ''; + }; + enableACME = true; + forceSSL = true; + }; + + services.prometheus = { + enable = true; + port = 9001; + scrapeConfigs = [ { + job_name = "tracktrain"; + static_configs = [{ + targets = [ "192.168.42.41:4000" ]; + }]; + } ]; + }; + + services.grafana = { + enable = true; + domain = "tracktrain.ilztalbahn.eu"; + rootUrl = "%(protocol)s://%(domain)s:/metrics/"; + port = 2342; + addr = "0.0.0.0"; + extraOptions.serve_from_sub_path = "true"; + + provision = { + enable = true; + datasources = [ { + url = "http://localhost:9001"; + type = "prometheus"; + name = "prometheus"; + } ]; + }; + }; networking.firewall.allowedTCPPorts = [ 443 ]; @@ -56,7 +106,7 @@ in sed -i "s/^>=.*//g" *.cabal sed -i "s/>=.*//g" *.cabal ''; })) - }/bin/tracktrain --dbString="dbname=tracktrain user=tracktrain" --warp.port=4000 + }/bin/tracktrain --dbString="dbname=tracktrain user=tracktrain" --warp.port=4000 +RTS -T ''; startAt = "daily"; }; |