mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 21:01:34 +01:00
alloy: Add caddy metrics scraping
This commit is contained in:
parent
926716e7e5
commit
1515ce28e4
4 changed files with 27 additions and 3 deletions
|
|
@ -82,6 +82,7 @@
|
||||||
collect.metrics = {
|
collect.metrics = {
|
||||||
system = true;
|
system = true;
|
||||||
victorialogs = true;
|
victorialogs = true;
|
||||||
|
caddy = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,10 @@
|
||||||
alloy = {
|
alloy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "alloy-${config.networking.hostName}.${tailscaleDomain}";
|
domain = "alloy-${config.networking.hostName}.${tailscaleDomain}";
|
||||||
collect.metrics.system = true;
|
collect.metrics = {
|
||||||
|
system = true;
|
||||||
|
caddy = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
caddy.virtualHosts =
|
caddy.virtualHosts =
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,10 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "alloy-${config.networking.hostName}.${config.custom.services.tailscale.domain}";
|
domain = "alloy-${config.networking.hostName}.${config.custom.services.tailscale.domain}";
|
||||||
collect = {
|
collect = {
|
||||||
metrics.system = true;
|
metrics = {
|
||||||
|
system = true;
|
||||||
|
caddy = true;
|
||||||
|
};
|
||||||
logs.sshd = true;
|
logs.sshd = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ in
|
||||||
metrics = {
|
metrics = {
|
||||||
system = lib.mkEnableOption "";
|
system = lib.mkEnableOption "";
|
||||||
victorialogs = lib.mkEnableOption "";
|
victorialogs = lib.mkEnableOption "";
|
||||||
|
caddy = lib.mkEnableOption "";
|
||||||
};
|
};
|
||||||
logs.sshd = lib.mkEnableOption "";
|
logs.sshd = lib.mkEnableOption "";
|
||||||
};
|
};
|
||||||
|
|
@ -36,6 +37,10 @@ in
|
||||||
assertion = cfg.collect.metrics.victorialogs -> config.services.victorialogs.enable;
|
assertion = cfg.collect.metrics.victorialogs -> config.services.victorialogs.enable;
|
||||||
message = "Collecting VictoriaLogs metrics requires the VictoriaLogs service to be enabled.";
|
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;
|
assertion = cfg.collect.logs.sshd -> config.services.openssh.enable;
|
||||||
message = "Collecting OpenSSH logs requires the OpenSSH service to be enabled.";
|
message = "Collecting OpenSSH logs requires the OpenSSH service to be enabled.";
|
||||||
|
|
@ -101,7 +106,19 @@ in
|
||||||
prometheus.scrape "victorialogs" {
|
prometheus.scrape "victorialogs" {
|
||||||
targets = [{
|
targets = [{
|
||||||
__address__ = "localhost:${builtins.toString config.custom.services.victorialogs.port}",
|
__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,
|
instance = constants.hostname,
|
||||||
}]
|
}]
|
||||||
forward_to = [prometheus.remote_write.default.receiver]
|
forward_to = [prometheus.remote_write.default.receiver]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue