{ config, pkgs, ... }: let configure_prom = builtins.toFile "prometheus.yml" '' scrape_configs: # System metrics - job_name: 'node' stream_parse: true static_configs: - targets: - ${config.networking.hostName}:9100 # Systemd service monitoring - job_name: 'systemd' metrics_path: /metrics params: collect[]: - 'systemd.service.state' - 'systemd.service.start_time_seconds' - 'systemd.unit_file.state' static_configs: - targets: - ${config.networking.hostName}:9100 relabel_configs: - source_labels: [__name__] regex: 'node_systemd_unit_state' action: keep - source_labels: [name] regex: '(ai-mailer|container@git|microvm@git-runner-).*\.service' action: keep ''; in { sops.secrets.victoria-agent-env = { sopsFile = ../utils/modules/victoriametrics/secrets.yaml; }; services.prometheus.exporters.node = { enable = true; enabledCollectors = [ "systemd" ]; }; systemd.services.export-fw-to-prometheus = { path = with pkgs; [victoriametrics]; enable = true; after = ["network-online.target"]; wants = ["network-online.target"]; wantedBy = ["multi-user.target"]; script = "vmagent -promscrape.config=${configure_prom} -envflag.enable -remoteWrite.url=https://victoria-server.cloonar.com/api/v1/write"; serviceConfig = { EnvironmentFile=config.sops.secrets.victoria-agent-env.path; }; }; }