I’ve setup Prometheus scrapeConfigs in NixOS but now I have to switch from Prometheus to VictoriaMetrics.
VictoriaMetrics uses the same scrape config but I have to pass the prometheus.yml file. This file is built by the Prometheus nix module and placed in the nix store here.
Can I refer to this generated file in the nix store? Something like this:
That should regenerate promethesYmlOut, though I don’t see that used elsewhere in the module so I’m not 100% sure that’ll work. The default stateDir is prometheus2. So maybe check to see if /var/lib/prometheus2/prometheus-substitued.yml exists on your system as a sanity check first.
It would have be nice to have NixOS/Prometheus build the scrape config because of syntax checks at nix build time. But it doesn’t work like that: The config file is only built when Prometheus is enabled – however it does not make sense to enable Prometheus and VictoriaMetrics with the same scrape config.
My attempts
Thank you aljenadroooo! I tested your suggestion but turns out that prometheus.yaml is actually in /etc/prometheus/, not /var/lib/ (on my NixOS 22.11). That would be good enough – but see above, I tried to walk the wrong way ^^