infrastructure/machines/storage01/prometheus.nix
sinavir d5d21ec204
Some checks failed
build configuration / build_web02 (push) Successful in 1m3s
build configuration / build_storage01 (push) Successful in 1m16s
build configuration / build_compute01 (push) Successful in 1m21s
build configuration / build_vault01 (push) Successful in 1m21s
build configuration / build_web01 (push) Successful in 1m36s
lint / check (push) Successful in 27s
build configuration / build_rescue01 (push) Successful in 55s
build configuration / push_to_cache (push) Successful in 2m13s
Check meta / check_meta (pull_request) Successful in 23s
Check meta / check_dns (pull_request) Successful in 45s
build configuration / build_vault01 (pull_request) Successful in 1m7s
build configuration / build_storage01 (pull_request) Successful in 1m10s
build configuration / build_compute01 (pull_request) Successful in 1m16s
build configuration / build_web02 (pull_request) Successful in 54s
build configuration / build_web01 (pull_request) Successful in 1m31s
build configuration / build_rescue01 (pull_request) Successful in 52s
build configuration / push_to_cache (pull_request) Failing after 2m13s
fix(prometheus-nut-exporter): make it work
2024-04-22 08:28:40 +02:00

87 lines
1.9 KiB
Nix

{
config,
nodes,
lib,
...
}:
let
host = "prometheus.dgnum.eu";
port = 9091;
nodeExporterConfigs = lib.flatten (
lib.mapAttrsToList (
node:
{ config, ... }:
lib.optional config.dgn-node-monitoring.enable {
targets = [ "${node}.dgnum:${builtins.toString config.dgn-node-monitoring.port}" ];
labels = {
host = node;
};
}
) nodes
);
in
{
services.prometheus = {
enable = true;
inherit port;
checkConfig = "syntax-only";
enableReload = true;
listenAddress = "127.0.0.1";
webConfigFile = config.age.secrets."prometheus-web_config_file".path;
webExternalUrl = "https://${host}";
retentionTime = "1y";
extraFlags = [ "--storage.tsdb.retention.size=20GB" ];
globalConfig = {
scrape_interval = "15s"; # if you change this settings, please do it in grafana also
};
scrapeConfigs = [
{
job_name = "prometheus";
static_configs = [ { targets = [ "localhost:9090" ]; } ];
}
{
job_name = "node_exporter";
static_configs = nodeExporterConfigs;
}
{
job_name = "uptime_kuma";
scheme = "https";
static_configs = [ { targets = [ "status.dgnum.eu" ]; } ];
basic_auth = {
username = "prometheus";
password_file = config.age.secrets."prometheus-uptime-kuma-apikey".path;
};
}
{
job_name = "hyp01_ups";
metrics_path = "/ups_metrics";
static_configs = [ { targets = [ "100.80.255.180:9199" ]; } ];
}
];
};
services.nginx.virtualHosts.${host} = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${builtins.toString port}";
proxyWebsockets = true;
recommendedProxySettings = true;
};
};
age-secrets.autoMatch = [ "prometheus" ];
}