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
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")

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

View file

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