modules/monitoring: convert to cluster service

This commit is contained in:
Max Headroom 2022-08-03 23:36:11 +02:00
parent 1dae0738eb
commit c8beafd021
4 changed files with 31 additions and 18 deletions

View file

@ -1,6 +1,6 @@
{ config, hosts, lib, pkgs, ... }: { cluster, config, lib, pkgs, ... }:
let let
myNode = hosts.${config.networking.hostName}; myNode = cluster.config.vars.mesh.${cluster.config.vars.hostName};
writeJSON = filename: data: pkgs.writeText filename (builtins.toJSON data); writeJSON = filename: data: pkgs.writeText filename (builtins.toJSON data);
@ -8,35 +8,28 @@ let
source_labels = [ from ]; source_labels = [ from ];
target_label = to; target_label = to;
}; };
in in {
{
# remote loki
links.loki = {
protocol = "http";
ipv4 = hosts.VEGAS.hypr.addr;
};
services.journald.extraConfig = "Storage=volatile"; services.journald.extraConfig = "Storage=volatile";
services.prometheus.exporters = { services.prometheus.exporters = {
node = { node = {
enable = true; enable = true;
listenAddress = myNode.hypr.addr; listenAddress = myNode.meshIp;
}; };
jitsi = { jitsi = {
enable = config.services.jitsi-meet.enable; enable = config.services.jitsi-meet.enable;
listenAddress = myNode.hypr.addr; listenAddress = myNode.meshIp;
interval = "60s"; interval = "60s";
}; };
}; };
systemd.services.prometheus-node-exporter = { systemd.services.prometheus-node-exporter = {
after = [ "hyprspace.service" "sys-devices-virtual-net-hyprspace.device" ]; after = [ "wireguard-wgmesh.service" ];
serviceConfig.RestartSec = "10s"; serviceConfig.RestartSec = "10s";
}; };
systemd.services.prometheus-jitsi-exporter = { systemd.services.prometheus-jitsi-exporter = {
after = [ "hyprspace.service" "sys-devices-virtual-net-hyprspace.device" ]; after = [ "wireguard-wgmesh.service" ];
serviceConfig.RestartSec = "10s"; serviceConfig.RestartSec = "10s";
}; };
@ -48,14 +41,14 @@ in
server.disable = true; server.disable = true;
positions.filename = "\${STATE_DIRECTORY:/tmp}/promtail-positions.yaml"; positions.filename = "\${STATE_DIRECTORY:/tmp}/promtail-positions.yaml";
clients = [ clients = [
{ url = "${config.links.loki.url}/loki/api/v1/push"; } { url = "${cluster.config.links.loki-ingest.url}/loki/api/v1/push"; }
]; ];
scrape_configs = [ scrape_configs = [
{ {
job_name = "journal"; job_name = "journal";
journal = { journal = {
max_age = "12h"; max_age = "12h";
labels.host = config.networking.hostName; labels.host = cluster.config.vars.hostName;
}; };
relabel_configs = [ relabel_configs = [
(relabel "__journal__systemd_unit" "systemd_unit") (relabel "__journal__systemd_unit" "systemd_unit")

View file

@ -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;
};
};
}

View file

@ -12,6 +12,10 @@ let
getExtAddr = host: host.interfaces.primary.addrPublic or host.interfaces.primary.addr; getExtAddr = host: host.interfaces.primary.addrPublic or host.interfaces.primary.addr;
in in
{ {
vars.mesh = {
VEGAS = config.links.mesh-node-VEGAS.extra;
prophet = config.links.mesh-node-prophet.extra;
};
links = { links = {
mesh-node-VEGAS = { mesh-node-VEGAS = {
ipv4 = getExtAddr hosts.VEGAS; ipv4 = getExtAddr hosts.VEGAS;

View file

@ -12,7 +12,6 @@ let
ipfs = import ./ipfs; ipfs = import ./ipfs;
maintenance = import ./maintenance; maintenance = import ./maintenance;
minimal = import ./minimal; minimal = import ./minimal;
monitoring = import ./monitoring;
motd = import ./motd; motd = import ./motd;
nix-builder = import ./nix-builder; nix-builder = import ./nix-builder;
nix-config-server = import ./nix-config/server.nix; nix-config-server = import ./nix-config/server.nix;
@ -43,7 +42,6 @@ in rec {
server = [ server = [
deploy-rs-receiver deploy-rs-receiver
fail2ban fail2ban
monitoring
motd motd
nix-config-server nix-config-server
system-info system-info