mirror of
https://github.com/nickolaj-jepsen/nixos.git
synced 2026-01-22 16:16:50 +01:00
refactor: move homelab config to module
This commit is contained in:
parent
742a55e5a0
commit
e03f3af01d
19 changed files with 123 additions and 62 deletions
54
modules/homelab/prometheus.nix
Normal file
54
modules/homelab/prometheus.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
config,
|
||||
hostname,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable (let
|
||||
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"
|
||||
];
|
||||
};
|
||||
};
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue