From a2a82dc09d8fb182b6618ee0e9ede189b0aa4411 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Thu, 6 Apr 2023 13:44:46 +0200 Subject: Fix prometheus? --- host/Spacebar-monitoring/configuration.nix | 15 ++--- modules/auto-redeploy.nix | 90 +++++++++++++++--------------- 2 files changed, 49 insertions(+), 56 deletions(-) diff --git a/host/Spacebar-monitoring/configuration.nix b/host/Spacebar-monitoring/configuration.nix index 4ecb682..836eda2 100755 --- a/host/Spacebar-monitoring/configuration.nix +++ b/host/Spacebar-monitoring/configuration.nix @@ -23,14 +23,8 @@ enable = true; stateDir = "prometheus"; extraFlags = [ - "--storage.local.retention 8760h" - "--storage.local.series-file-shrink-ratio 0.3" - "--storage.local.memory-chunks 2097152" - "--storage.local.max-chunks-to-persist 1048576" - "--storage.local.index-cache-size.fingerprint-to-metric 2097152" - "--storage.local.index-cache-size.fingerprint-to-timerange 1048576" - "--storage.local.index-cache-size.label-name-to-label-values 2097152" - "--storage.local.index-cache-size.label-pair-to-fingerprints 41943040" + "--storage.tsdb.retention.time=1y" + "--storage.tsdb.path=/var/lib/prometheus/" ]; # alertmanagerURL = [ "http://localhost:9093" ]; # rules = [ @@ -212,14 +206,13 @@ }; grafana = { enable = true; - addr = "0.0.0.0"; - domain = "grafana.spacebar.chat"; settings = { server = { root_url = "https://grafana.spacebar.chat/"; enable_gzip = true; domain = "grafana.spacebar.chat"; - + http_addr = "0.0.0.0"; + domain = "grafana.spacebar.chat"; }; analytics.reporting_enabled = false; security.secret_key = secrets.secret_keys.grafana; diff --git a/modules/auto-redeploy.nix b/modules/auto-redeploy.nix index c50b98e..01b54ad 100644 --- a/modules/auto-redeploy.nix +++ b/modules/auto-redeploy.nix @@ -16,53 +16,53 @@ "auto-redeploy" = { stopIfChanged = false; restartIfChanged = false; - #wantedBy = [ "multi-user.target" ]; - #after = [ "network.target" ]; - path = with pkgs; [ git curl nix nixos-install-tools nixos-rebuild ]; - serviceConfig = { - ExecStart = pkgs.writeShellScript "auto-redeploy" '' - cd /Spacebar-Open-Architecture - #store current commit hash - echo "Current commit: $(git rev-parse HEAD)" - currentCommit=$(git rev-parse HEAD) - git fetch --all - #check if there are any new commits - echo "Checking for new commits..." - echo "Local: $(git rev-parse HEAD)" - echo "Remote: $(git rev-parse @{u})" - if [ $(git rev-parse HEAD) = $(git rev-parse @{u}) ]; then - echo "Already up-to-date" - exit 0 - fi - curl -S -H "Content-Type: application/json" -d '{"username": "${config.networking.hostName} - redeploy", "content": "System started redeploy."}' ${secrets.webhooks.discord.deploy} - #pull new commits - git pull - #send commit log to discord - #curl -S -F "file=@<(git log --pretty=format:'%h - %s (%an, %ar)' $currentCommit..HEAD)" -F "filename=commit.log" -F "content=Adding commits" -H "Content-Type: multipart/form-data" ${secrets.webhooks.discord.deploy} - - - - #call ./update.sh and store output (including stderr) in a file - ( - nix flake update - nixos-generate-config --show-hardware-config > hardware-configuration.nix - git add -f hardware-configuration.nix - nixos-rebuild switch --flake ".#${config.networking.hostName}" -j`nproc` --upgrade-all - git rm --cached hardware-configuration.nix - ) 2>&1 | tee /tmp/update.log - #send the output to discord as a file, with hostname as username, use paload_json - curl -S -F "file=@/tmp/update.log" -F "filename=update.log" -F 'payload_json={"username": "${config.networking.hostName} - redeploy", "content": "Redeploy finished! Logs:"}' -H "Content-Type: multipart/form-data" ${secrets.webhooks.discord.deploy} - + #wantedBy = [ "multi-user.target" ]; + #after = [ "network.target" ]; + path = with pkgs; [ git curl nix nixos-install-tools nixos-rebuild ]; + serviceConfig = { + ExecStart = pkgs.writeShellScript "auto-redeploy" '' + cd /Spacebar-Open-Architecture + #store current commit hash + echo "Current commit: $(git rev-parse HEAD)" + currentCommit=$(git rev-parse HEAD) + git fetch --all + #check if there are any new commits + echo "Checking for new commits..." + echo "Local: $(git rev-parse HEAD)" + echo "Remote: $(git rev-parse @{u})" + if [ $(git rev-parse HEAD) = $(git rev-parse @{u}) ]; then + echo "Already up-to-date" + exit 0 + fi + curl -S -H "Content-Type: application/json" -d '{"username": "${config.networking.hostName} - redeploy", "content": "System started redeploy."}' ${secrets.webhooks.discord.deploy} + #pull new commits + git pull + #send commit log to discord + #curl -S -F "file=@<(git log --pretty=format:'%h - %s (%an, %ar)' $currentCommit..HEAD)" -F "filename=commit.log" -F "content=Adding commits" -H "Content-Type: multipart/form-data" ${secrets.webhooks.discord.deploy} + + + + #call ./update.sh and store output (including stderr) in a file + ( + nix flake update + nixos-generate-config --show-hardware-config > hardware-configuration.nix + git add -f hardware-configuration.nix + nixos-rebuild switch --flake ".#${config.networking.hostName}" -j`nproc` --upgrade-all + git rm --cached hardware-configuration.nix + ) 2>&1 | tee /tmp/update.log + #send the output to discord as a file, with hostname as username, use paload_json + curl -S -F "file=@/tmp/update.log" -F "filename=update.log" -F 'payload_json={"username": "${config.networking.hostName} - redeploy", "content": "Redeploy finished! Logs:"}' -H "Content-Type: multipart/form-data" ${secrets.webhooks.discord.deploy} + - - #store current commit in file - echo $(git rev-parse HEAD) > currentCommit - ''; - #Restart = "always"; - #RestartSec = 60; - User = "root"; - }; + + #store current commit in file + echo $(git rev-parse HEAD) > currentCommit + ''; + #Restart = "always"; + #RestartSec = 60; + User = "root"; + }; }; }; } -- cgit 1.4.1