From c8beafd0215fa2f105193fa3b0697bb2eb2b88fc Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 3 Aug 2022 23:36:11 +0200 Subject: [PATCH] modules/monitoring: convert to cluster service --- .../services/monitoring/client.nix | 25 +++++++------------ cluster/services/monitoring/default.nix | 18 +++++++++++++ cluster/services/wireguard/default.nix | 4 +++ modules/default.nix | 2 -- 4 files changed, 31 insertions(+), 18 deletions(-) rename modules/monitoring/default.nix => cluster/services/monitoring/client.nix (75%) create mode 100644 cluster/services/monitoring/default.nix diff --git a/modules/monitoring/default.nix b/cluster/services/monitoring/client.nix similarity index 75% rename from modules/monitoring/default.nix rename to cluster/services/monitoring/client.nix index adfa336..0fd571d 100644 --- a/modules/monitoring/default.nix +++ b/cluster/services/monitoring/client.nix @@ -1,6 +1,6 @@ -{ config, hosts, lib, pkgs, ... }: +{ cluster, config, lib, pkgs, ... }: let - myNode = hosts.${config.networking.hostName}; + myNode = cluster.config.vars.mesh.${cluster.config.vars.hostName}; writeJSON = filename: data: pkgs.writeText filename (builtins.toJSON data); @@ -8,35 +8,28 @@ let source_labels = [ from ]; target_label = to; }; -in -{ - # remote loki - links.loki = { - protocol = "http"; - ipv4 = hosts.VEGAS.hypr.addr; - }; - +in { services.journald.extraConfig = "Storage=volatile"; services.prometheus.exporters = { node = { enable = true; - listenAddress = myNode.hypr.addr; + listenAddress = myNode.meshIp; }; jitsi = { enable = config.services.jitsi-meet.enable; - listenAddress = myNode.hypr.addr; + listenAddress = myNode.meshIp; interval = "60s"; }; }; systemd.services.prometheus-node-exporter = { - after = [ "hyprspace.service" "sys-devices-virtual-net-hyprspace.device" ]; + after = [ "wireguard-wgmesh.service" ]; serviceConfig.RestartSec = "10s"; }; systemd.services.prometheus-jitsi-exporter = { - after = [ "hyprspace.service" "sys-devices-virtual-net-hyprspace.device" ]; + after = [ "wireguard-wgmesh.service" ]; serviceConfig.RestartSec = "10s"; }; @@ -48,14 +41,14 @@ in server.disable = true; positions.filename = "\${STATE_DIRECTORY:/tmp}/promtail-positions.yaml"; clients = [ - { url = "${config.links.loki.url}/loki/api/v1/push"; } + { url = "${cluster.config.links.loki-ingest.url}/loki/api/v1/push"; } ]; scrape_configs = [ { job_name = "journal"; journal = { max_age = "12h"; - labels.host = config.networking.hostName; + labels.host = cluster.config.vars.hostName; }; relabel_configs = [ (relabel "__journal__systemd_unit" "systemd_unit") diff --git a/cluster/services/monitoring/default.nix b/cluster/services/monitoring/default.nix new file mode 100644 index 0000000..98e3188 --- /dev/null +++ b/cluster/services/monitoring/default.nix @@ -0,0 +1,18 @@ +{ config, ... }: + +{ + links = { + loki-ingest = { + protocol = "http"; + ipv4 = config.vars.mesh.VEGAS.meshIp; + }; + }; + services.monitoring = { + nodes = { + client = [ "VEGAS" "prophet" ]; + }; + nixos = { + client = ./client.nix; + }; + }; +} diff --git a/cluster/services/wireguard/default.nix b/cluster/services/wireguard/default.nix index d9d8d77..bcebe6f 100644 --- a/cluster/services/wireguard/default.nix +++ b/cluster/services/wireguard/default.nix @@ -12,6 +12,10 @@ let getExtAddr = host: host.interfaces.primary.addrPublic or host.interfaces.primary.addr; in { + vars.mesh = { + VEGAS = config.links.mesh-node-VEGAS.extra; + prophet = config.links.mesh-node-prophet.extra; + }; links = { mesh-node-VEGAS = { ipv4 = getExtAddr hosts.VEGAS; diff --git a/modules/default.nix b/modules/default.nix index 45c50a6..0d8d559 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -12,7 +12,6 @@ let ipfs = import ./ipfs; maintenance = import ./maintenance; minimal = import ./minimal; - monitoring = import ./monitoring; motd = import ./motd; nix-builder = import ./nix-builder; nix-config-server = import ./nix-config/server.nix; @@ -43,7 +42,6 @@ in rec { server = [ deploy-rs-receiver fail2ban - monitoring motd nix-config-server system-info