Add debug logging to systemd collector to diagnose failure

Add detailed debug logging to track where the systemd collector is failing.
This will help identify why the collector returns an error during startup.
This commit is contained in:
Christoffer Martinsson 2025-10-23 11:56:33 +02:00
parent f3a81f7a0d
commit df87baa9dd

View File

@ -132,6 +132,7 @@ impl SystemdCollector {
/// Auto-discover interesting services to monitor and cache their status
fn discover_services(&self) -> Result<Vec<String>> {
debug!("Starting systemd service discovery");
let units_output = Command::new("systemctl")
.arg("list-units")
.arg("--type=service")
@ -213,7 +214,7 @@ impl SystemdCollector {
state.service_status_cache = status_cache;
}
debug!("Service discovery completed: found {} matching services", services.len());
debug!("Service discovery completed: found {} matching services: {:?}", services.len(), services);
if services.is_empty() {
debug!("No services found matching the configured filters - this is a valid state");
}
@ -379,7 +380,10 @@ impl Collector for SystemdCollector {
// Get cached services (discovery only happens when needed)
let monitored_services = match self.get_monitored_services() {
Ok(services) => services,
Ok(services) => {
debug!("Successfully got {} monitored services", services.len());
services
},
Err(e) => {
debug!("Failed to get monitored services: {}", e);
return Ok(metrics);