Show the resolved default settings path in --help; add Prometheus/OpenMetrics polling

--settings-path's help text now names the actual resolved default path
(computed once via LazyLock) instead of only describing where to look for
one. Also adds an optional --metrics-url flag that polls a Prometheus/
OpenMetrics-compatible endpoint on an interval, pushing samples straight
into a metric's bucket (bypassing log-line regex matching) so they're
queryable via PromQL/dashboards alongside log-derived metrics.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
Hugh Kaznowski
2026-09-05 18:16:13 +01:00
co-authored by Claude Sonnet 5
parent 18c2d72d22
commit 12381545c8
3 changed files with 167 additions and 4 deletions
+21 -3
View File
@@ -14,7 +14,7 @@ mod settings;
mod timestamp;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::sync::{Arc, LazyLock, Mutex};
use clap::Parser;
use tokio::net::TcpListener;
@@ -23,6 +23,17 @@ use tokio::sync::mpsc;
use profile::ProfileStore;
use settings::Settings;
/// The resolved default settings path, rendered into `--help` so `--settings-path`'s help text
/// names a real, concrete location instead of only describing where to look for one.
static SETTINGS_PATH_HELP: LazyLock<String> = LazyLock::new(|| {
format!(
"Path to the settings file. Defaults to {}.",
settings::default_settings_path()
.map(|path| path.display().to_string())
.unwrap_or_else(|| "a per-OS config location".to_string())
)
});
/// Observability dashboard from terminal output.
#[derive(Parser, Debug)]
struct Args {
@@ -31,13 +42,16 @@ struct Args {
#[arg(long, default_value_t = 0)]
port: u16,
/// Path to the settings file. Defaults to a per-OS config location.
#[arg(long)]
#[arg(long, help = SETTINGS_PATH_HELP.as_str())]
settings_path: Option<PathBuf>,
/// File to tail for log lines, instead of reading from stdin. Behaves like `tail -f`.
#[arg(long)]
file: Option<PathBuf>,
/// URL of a Prometheus/OpenMetrics-compatible endpoint to poll for metrics, in addition to log ingestion.
#[arg(long)]
metrics_url: Option<String>,
}
#[tokio::main]
@@ -94,6 +108,10 @@ async fn main() {
}
}
if let Some(metrics_url) = args.metrics_url.clone() {
tokio::spawn(ingest::run_metrics_poll(engine_tx.clone(), metrics_url));
}
let app = api::router(engine_tx, settings, settings_path);
let listener = TcpListener::bind(("0.0.0.0", args.port))
.await