2025-04-26 20:02:56 +02:00
|
|
|
{
|
|
|
|
|
config,
|
2025-12-12 04:30:57 +01:00
|
|
|
lib,
|
2025-04-26 20:02:56 +02:00
|
|
|
...
|
2025-12-12 04:30:57 +01:00
|
|
|
}:
|
|
|
|
|
lib.mkIf config.fireproof.homelab.enable (let
|
2025-12-13 21:41:52 +01:00
|
|
|
inherit (config.fireproof) hostname;
|
2025-04-26 20:02:56 +02:00
|
|
|
mkScrapeConfig = name: {
|
|
|
|
|
job_name = name;
|
|
|
|
|
static_configs = [
|
|
|
|
|
{
|
|
|
|
|
labels = {
|
|
|
|
|
instance = hostname;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
targets = [
|
|
|
|
|
"${toString config.services.prometheus.exporters.${name}.listenAddress}:${toString config.services.prometheus.exporters.${name}.port}"
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
in {
|
|
|
|
|
age.secrets.grafana-cloud-prometheus-api-key = {
|
|
|
|
|
rekeyFile = ../../secrets/grafana-cloud-prometheus.age;
|
|
|
|
|
owner = "prometheus";
|
|
|
|
|
group = "prometheus";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.prometheus = {
|
|
|
|
|
enable = true;
|
|
|
|
|
enableAgentMode = true;
|
|
|
|
|
globalConfig.scrape_interval = "1m";
|
|
|
|
|
remoteWrite = [
|
|
|
|
|
{
|
|
|
|
|
url = "https://prometheus-prod-01-eu-west-0.grafana.net/api/prom/push";
|
|
|
|
|
basic_auth = {
|
|
|
|
|
username = "432120";
|
|
|
|
|
password_file = "${config.age.secrets.grafana-cloud-prometheus-api-key.path}";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
scrapeConfigs = [
|
|
|
|
|
(mkScrapeConfig "node")
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
exporters.node = {
|
|
|
|
|
enable = true;
|
|
|
|
|
extraFlags = [
|
|
|
|
|
"--web.disable-exporter-metrics"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
2025-12-12 04:30:57 +01:00
|
|
|
})
|