2024-09-14 19:36:59 +05:30
|
|
|
{ lib, config, ... }:
|
|
|
|
let
|
2024-10-27 23:09:50 +05:30
|
|
|
inherit (import ./caddy-helpers.nix) logFormat tlsAcmeDnsChallenge;
|
2024-09-14 19:36:59 +05:30
|
|
|
in
|
|
|
|
{
|
2024-07-18 22:03:46 +05:30
|
|
|
services = {
|
2024-09-14 19:36:59 +05:30
|
|
|
caddy =
|
|
|
|
let
|
|
|
|
vHost = "${config.networking.hostName}.labs.adtya.xyz";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
virtualHosts."${vHost}" = {
|
2024-10-27 23:09:50 +05:30
|
|
|
inherit logFormat;
|
2024-09-14 19:36:59 +05:30
|
|
|
extraConfig = ''
|
2024-10-27 23:09:50 +05:30
|
|
|
${tlsAcmeDnsChallenge}
|
2024-09-14 19:36:59 +05:30
|
|
|
metrics /caddy-metrics
|
|
|
|
handle /metrics {
|
2024-09-19 19:08:58 +05:30
|
|
|
reverse_proxy ${config.services.prometheus.exporters.node.listenAddress}:${toString config.services.prometheus.exporters.node.port}
|
|
|
|
}
|
|
|
|
handle /smartctl-metrics {
|
|
|
|
uri replace /smartctl-metrics /metrics
|
|
|
|
reverse_proxy ${config.services.prometheus.exporters.smartctl.listenAddress}:${toString config.services.prometheus.exporters.smartctl.port}
|
2024-09-14 19:36:59 +05:30
|
|
|
}
|
|
|
|
handle /systemd-metrics {
|
|
|
|
uri replace /systemd-metrics /metrics
|
2024-09-19 19:08:58 +05:30
|
|
|
reverse_proxy ${config.services.prometheus.exporters.systemd.listenAddress}:${toString config.services.prometheus.exporters.systemd.port}
|
2024-09-14 19:36:59 +05:30
|
|
|
}
|
|
|
|
${lib.optionalString config.services.prometheus.exporters.postgres.enable ''
|
|
|
|
handle /postgres-metrics {
|
|
|
|
uri replace /postgres-metrics /metrics
|
|
|
|
reverse_proxy ${config.services.prometheus.exporters.postgres.listenAddress}:${toString config.services.prometheus.exporters.postgres.port}
|
|
|
|
}
|
|
|
|
''}
|
2024-10-29 00:51:16 +05:30
|
|
|
${lib.optionalString config.services.prometheus.exporters.redis.enable ''
|
|
|
|
handle /redis-metrics {
|
|
|
|
uri replace /redis-metrics /metrics
|
|
|
|
reverse_proxy ${config.services.prometheus.exporters.redis.listenAddress}:${toString config.services.prometheus.exporters.redis.port}
|
|
|
|
}
|
|
|
|
''}
|
2024-09-14 19:36:59 +05:30
|
|
|
'';
|
|
|
|
};
|
2024-07-18 22:03:46 +05:30
|
|
|
};
|
2024-07-18 23:00:17 +05:30
|
|
|
prometheus.exporters = {
|
|
|
|
node = {
|
|
|
|
enable = true;
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
port = 9100;
|
2024-07-19 19:42:15 +05:30
|
|
|
enabledCollectors = [ "systemd" "processes" ];
|
2024-07-18 23:00:17 +05:30
|
|
|
};
|
2024-09-19 19:08:58 +05:30
|
|
|
smartctl = {
|
|
|
|
enable = true;
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
port = 9633;
|
|
|
|
};
|
2024-07-18 23:00:17 +05:30
|
|
|
systemd = {
|
|
|
|
enable = true;
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
port = 9558;
|
|
|
|
};
|
|
|
|
|
2024-07-18 22:03:46 +05:30
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|