@cryptotaxi247 / netdata-1 / commits / 6851d51cb

Create journal directory if missing before watching (#22019)

If the otel-signal-viewer plugin starts before the otel plugin, the journal directory (e.g. /var/log/netdata/otel/v1) might not yet exist. This causes inotify watch setup to fail, and the viewer never picks up logs even after the otel plugin creates the directory and starts writing. Create the directory with create_dir_all before setting up the watch. This is safe because the otel plugin also uses create_dir_all (to create a machine-id subdirectory inside it), which is idempotent.

vkalintiris committed Mar 23, 2026 at 20:25 UTC 6851d51cbe392c4a762825d7148205803014de6d
1 file changed +8
src/crates/netdata-log-viewer/otel-signal-viewer-plugin/src/main.rs
+8
@@ -81,6 +81,14 @@ async fn run_plugin() -> std::result::Result<(), Box<dyn std::error::Error>> {
81
82 // Watch configured journal directories
83 for path in &config.journal.paths {
84 + // Create the directory if it doesn't exist so inotify can watch it.
85 + // The otel plugin creates it too (via create_dir_all), but it may start later.
86 + if !std::path::Path::new(path).exists() {
87 + if let Err(e) = std::fs::create_dir_all(path) {
88 + error!("failed to create directory {}: {}", path, e);
89 + }
90 + }
91 +
92 if let Err(e) = catalog_function.watch_directory(path) {
93 error!("failed to watch directory {}: {:#?}", path, e);
94 }