Hello,
i am trying for a while to get a prometheus target running that requires a certificate file.
services.prometheus = {
enable = true;
scrapeConfigs = [
{
job_name = "incus";
metrics_path = "/1.0/metrics";
scheme = "https";
static_configs = [{
targets = ["1.2.3.4:8444" ];
}];
tls_config = {
insecure_skip_verify = true;
ca_file = "/etc/prometheus/tls/server.crt";
#cert_file = "${config.environment.etc."prometheus/tls/metrics.crt".target}";
cert_file = "/etc/prometheus/tls/metrics.crt";
key_file = "/etc/prometheus/tls/metrics.key";
};
}
];
};
The issue is, that no matter what, the build fails with
FAILED: error checking client cert file "/etc/prometheus/tls/metrics.crt": stat /etc/prometheus/tls/metrics.crt: no such file or directory
The issue is, that the /nix/store/8rwva8j1bwh5ig42dz4j9w7d5xf8h4fy-prometheus.yml-checkconfig-checked.drv builder calls “promtool check config” to verify the configuration file.
I tried many different places to store the certificates, but as far as i can see, the builder only sees the nix store.
I tried to place the files with environment.etc, but had no luck there. It does not seem to register the dependeny. (And putting the certificate key in the nix store is bad.)
I have also found no way to disable the checkconfig step in the build. So for this step to pass, the files have to be in the nix store.
Has anybody successfully configured prometheus this way?
Nils