# SPDX-FileCopyrightText: 2024 Tom Hubrecht # # SPDX-License-Identifier: EUPL-1.2 { config, lib, meta, name, nodeMeta, ... }: let inherit (lib) filterAttrs mapAttrsToList mkEnableOption mkIf ; cfg = config.dgn-monitoring; in { imports = [ ./exporters.nix ]; options.dgn-monitoring = { enable = mkEnableOption "the DGNum monitoring system" // { default = true; }; }; config = mkIf cfg.enable { services.vmagent = { enable = true; flags = { "remoteWrite.url" = "http://${meta.network.storage01.netbirdIp}:8428/api/v1/write"; "remoteWrite.label" = "node=${name}"; }; prometheusConfig = { scrape_configs = mapAttrsToList (job_name: cfg: { inherit job_name; static_configs = [ { targets = [ "127.0.0.1:${builtins.toString cfg.port}" ]; } ]; }) ( filterAttrs ( name: cfg: !(builtins.elem name [ "assertions" "warnings" "blackbox" "unifi-poller" "domain" "minio" "idrac" "pve" "tor" ]) && cfg.enable ) config.services.prometheus.exporters ); global = { scrape_interval = "15s"; external_labels.hostname = "${name}.${nodeMeta.site}.infra.dgnum.eu"; }; }; }; services.journald.upload = { enable = true; settings = { Upload.URL = "http://${meta.network.storage01.netbirdIp}:9428/insert/journald"; }; }; }; }