alloy: Add caddy metrics scraping

This commit is contained in:
SebastianStork 2025-09-22 00:28:47 +02:00
parent 926716e7e5
commit 1515ce28e4
4 changed files with 27 additions and 3 deletions

View file

@ -25,6 +25,7 @@ in
metrics = {
system = lib.mkEnableOption "";
victorialogs = lib.mkEnableOption "";
caddy = lib.mkEnableOption "";
};
logs.sshd = lib.mkEnableOption "";
};
@ -36,6 +37,10 @@ in
assertion = cfg.collect.metrics.victorialogs -> config.services.victorialogs.enable;
message = "Collecting VictoriaLogs metrics requires the VictoriaLogs service to be enabled.";
}
{
assertion = cfg.collect.metrics.caddy -> config.services.caddy.enable;
message = "Collecting Caddy metrics requires the Caddy service to be enabled.";
}
{
assertion = cfg.collect.logs.sshd -> config.services.openssh.enable;
message = "Collecting OpenSSH logs requires the OpenSSH service to be enabled.";
@ -101,7 +106,19 @@ in
prometheus.scrape "victorialogs" {
targets = [{
__address__ = "localhost:${builtins.toString config.custom.services.victorialogs.port}",
job = "victorialogs",
instance = constants.hostname,
}]
forward_to = [prometheus.remote_write.default.receiver]
scrape_interval = "15s"
}
'';
};
"alloy/caddy-metrics.alloy" = {
enable = cfg.collect.metrics.caddy;
text = ''
prometheus.scrape "caddy" {
targets = [{
__address__ = "localhost:2019",
instance = constants.hostname,
}]
forward_to = [prometheus.remote_write.default.receiver]