caddy: added metrics for caddy access log

This commit is contained in:
Tigor Hutasuhut 2024-09-16 10:32:43 +07:00
parent 4cd08447ae
commit f9caa0af7f
3 changed files with 54 additions and 0 deletions

View file

@ -69,5 +69,53 @@ in
'';
};
environment.etc."alloy/config.alloy".text =
/*hcl*/ ''
local.file_match "caddy_access_log" {
path_targets = [
{
"__path__" = "/var/log/caddy/*.log",
},
]
sync_period = "5s"
}
loki.source.file "caddy_access_log" {
targets = local.file_match.caddy_access_log.targets
forward_to = [loki.process.caddy_access_log.receiver]
}
loki.process "caddy_access_log" {
forward_to = [loki.write.default.receiver]
stage.json {
expressions = {
level = "",
host = "request.host",
method = "request.method",
proto = "request.proto",
}
}
stage.labels {
values = {
level = "",
host = "",
method = "",
proto = "",
}
}
stage.label_drop {
values = ["service_name"]
}
stage.static_labels {
values = {
job = "caddy_access_log",
}
}
}
'';
};
}

View file

@ -51,6 +51,10 @@ in
config.sops.templates."alloy-basic-auth".path
];
systemd.services.alloy.serviceConfig = {
User = "root";
};
environment.etc."alloy/config.alloy".text =
let

View file

@ -97,6 +97,8 @@ in
limits_config = {
retention_period = "90d";
ingestion_burst_size_mb = 64;
ingestion_rate_mb = 32;
};
storage_config = {