From 41567c9aa33f678e27548fdcc6e139417a195c7e Mon Sep 17 00:00:00 2001 From: muon Date: Sun, 2 Feb 2025 13:52:30 +0000 Subject: [PATCH] Add dash --- hosts/muho/configuration.nix | 1 + hosts/ports.nix | 1 + modules/nixos/server/dash.nix | 54 ++++++++++++++++++++++++++++++++ modules/nixos/server/default.nix | 1 + 4 files changed, 57 insertions(+) create mode 100644 modules/nixos/server/dash.nix diff --git a/hosts/muho/configuration.nix b/hosts/muho/configuration.nix index 24cfc2e..3372737 100644 --- a/hosts/muho/configuration.nix +++ b/hosts/muho/configuration.nix @@ -41,6 +41,7 @@ in { mods.server.git.enable = true; mods.server.cal.enable = true; mods.server.chat.enable = true; + mods.server.dash.enable = true; mods.server.vrising.enable = true; diff --git a/hosts/ports.nix b/hosts/ports.nix index e89ac4a..fc7fcfb 100644 --- a/hosts/ports.nix +++ b/hosts/ports.nix @@ -8,6 +8,7 @@ git = 3006; cal = 3007; chat = 3008; + dash = 3009; search = 8081; videos = 8082; diff --git a/modules/nixos/server/dash.nix b/modules/nixos/server/dash.nix new file mode 100644 index 0000000..0832afc --- /dev/null +++ b/modules/nixos/server/dash.nix @@ -0,0 +1,54 @@ +{ pkgs, lib, config, ... }: +let + cfg = config.mods.server; + port = cfg.nginx.ports.dash; +in with lib; { + options.mods.server = { + dash = { + enable = mkEnableOption { + default = false; + description = "enables metrics dashboard"; + }; + }; + }; + + config = mkIf cfg.dash.enable { + services.grafana = { + enable = true; + domain = "dash.muon.host"; + addr = "0.0.0.0"; + + provision.datasources.settings.datasources = [{ + name = "Prometheus"; + type = "Prometheus"; + url = "http://localhost:${toString config.services.prometheus.port}"; + }]; + + inherit port; + }; + + services.prometheus = { + enable = true; + port = 9001; + + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + port = 9002; + }; + }; + + scrapeConfigs = [{ + job_name = "muho"; + static_configs = [{ + targets = [ + "127.0.0.1:${ + toString config.services.prometheus.exporters.node.port + }" + ]; + }]; + }]; + }; + }; +} diff --git a/modules/nixos/server/default.nix b/modules/nixos/server/default.nix index 7a59b67..57cfd7e 100644 --- a/modules/nixos/server/default.nix +++ b/modules/nixos/server/default.nix @@ -19,5 +19,6 @@ ./git.nix ./cal.nix ./chat.nix + ./dash.nix ]; }