summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chaski/services/tracktrain.nix52
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";
};