diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..33a8a2b --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,8 @@ +{ + "permissions": { + "allow": [ + "Bash(cp:*)", + "Bash(grep:*)" + ] + } +} diff --git a/common/base.nix b/common/base.nix index 6eb3eb5..d26a08c 100644 --- a/common/base.nix +++ b/common/base.nix @@ -17,6 +17,12 @@ services.openssh.enable = true; + services.prometheus.exporters.node = { + enable = true; + openFirewall = false; + }; + networking.firewall.interfaces."tailscale0".allowedTCPPorts = [ 9100 ]; + nix.extraOptions = '' experimental-features = nix-command flakes ca-derivations warn-dirty = false diff --git a/flake.nix b/flake.nix index 588eb52..4b58722 100644 --- a/flake.nix +++ b/flake.nix @@ -110,6 +110,13 @@ target = "135.181.240.228"; }; + prometheus-hel = { + modules = [ + ./hosts/prometheus-hel/services/prometheus.nix + ]; + target = "62.238.19.177"; + }; + knot1 = { modules = [ tangled.nixosModules.knot diff --git a/hosts/prometheus-hel/configuration.nix b/hosts/prometheus-hel/configuration.nix new file mode 100644 index 0000000..67bdad7 --- /dev/null +++ b/hosts/prometheus-hel/configuration.nix @@ -0,0 +1,6 @@ +{...}: { + imports = [./disk-config.nix]; + networking.hostName = "prometheus-hel"; + users.users.tangler.extraGroups = []; + system.stateVersion = "25.05"; +} diff --git a/hosts/prometheus-hel/disk-config.nix b/hosts/prometheus-hel/disk-config.nix new file mode 100644 index 0000000..b57bf19 --- /dev/null +++ b/hosts/prometheus-hel/disk-config.nix @@ -0,0 +1,73 @@ +{lib, ...}: { + disko.devices = { + disk.disk1 = { + device = lib.mkDefault "/dev/sda"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; + }; + esp = { + name = "ESP"; + size = "500M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + name = "root"; + size = "100%"; + content = { + type = "lvm_pv"; + vg = "pool"; + }; + }; + }; + }; + }; + disk.disk2 = { + device = "/dev/sdb"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + data = { + name = "data"; + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/var/lib/prometheus2"; + mountOptions = [ "defaults" ]; + }; + }; + }; + }; + }; + lvm_vg = { + pool = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%FREE"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ + "defaults" + ]; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/prometheus-hel/services/prometheus.nix b/hosts/prometheus-hel/services/prometheus.nix new file mode 100644 index 0000000..b791ea7 --- /dev/null +++ b/hosts/prometheus-hel/services/prometheus.nix @@ -0,0 +1,69 @@ +{pkgs, lib, ...}: +let + nodeExporterDashboard = pkgs.fetchurl { + url = "https://grafana.com/api/dashboards/1860/revisions/latest/download"; + sha256 = "sha256-GExrdAnzBtp1Ul13cvcZRbEM6iOtFrXXjEaY6g6lGYY="; + }; +in +{ + services.prometheus = { + enable = true; + scrapeConfigs = [ + { + job_name = "appview-arn"; + static_configs = [{ targets = [ "appview-arn:9100" ]; }]; + } + { + job_name = "knot1-ams"; + static_configs = [{ targets = [ "knot1-ams:9100" ]; }]; + } + { + job_name = "mirror"; + static_configs = [{ targets = [ "mirror:9100" ]; }]; + } + { + job_name = "nixery"; + static_configs = [{ targets = [ "nixery:9100" ]; }]; + } + { + job_name = "spindle-hel"; + static_configs = [{ targets = [ "spindle-hel:9100" ]; }]; + } + { + job_name = "prometheus-hel"; + static_configs = [{ targets = [ "127.0.0.1:9100" ]; }]; + } + ]; + }; + + services.grafana = { + enable = true; + settings = { + server = { + http_addr = "0.0.0.0"; + http_port = 3000; + }; + }; + provision = { + enable = true; + datasources.settings.datasources = [ + { + name = "Prometheus"; + type = "prometheus"; + url = "http://127.0.0.1:${toString 9090}"; + isDefault = true; + } + ]; + dashboards.settings.providers = [ + { + name = "default"; + options.path = "/etc/grafana/dashboards"; + } + ]; + }; + }; + + environment.etc."grafana/dashboards/node-exporter.json".source = nodeExporterDashboard; + + networking.firewall.allowedTCPPorts = [ 3000 ]; +}