0.34.6_repo_cleanup
This commit is contained in:
1 parent
ce1a90397c
commit
133d2f0f91
273 files changed
+5969
-6926
No files matched your search
@@ -55,7 +55,6 @@ fn render_misc(app: &App, snapshot: &crate::config::Snapshot, f: &mut Families)
|
||||
&l,
|
||||
host.max_connections,
|
||||
);
|
||||
// Backend labels are bounded by configured stream/backend IDs; never client addresses.
|
||||
for backend in &view.backends {
|
||||
let lb = labels(&[
|
||||
("stream", &host.id),
|
||||
@@ -90,7 +89,6 @@ fn render_misc(app: &App, snapshot: &crate::config::Snapshot, f: &mut Families)
|
||||
&lb,
|
||||
u8::from(backend.drain),
|
||||
);
|
||||
// A disabled detailed-metrics flag does not affect routing counters or probes.
|
||||
if !backend.detail_enabled {
|
||||
continue;
|
||||
}
|
||||
@@ -161,8 +159,6 @@ fn render_misc(app: &App, snapshot: &crate::config::Snapshot, f: &mut Families)
|
||||
);
|
||||
}
|
||||
if settings.include_cache_domains {
|
||||
// Bounded resident inspector. Counter families are gauges deliberately:
|
||||
// these per-domain values reset on config publication, unlike globals.
|
||||
let dashboard = app.cache.dashboard(None, 0, 1);
|
||||
f.add(
|
||||
"rust_proxy_cache_statistics_revision",
|
||||
@@ -172,7 +168,6 @@ fn render_misc(app: &App, snapshot: &crate::config::Snapshot, f: &mut Families)
|
||||
dashboard.statistics_revision,
|
||||
);
|
||||
for domain in dashboard.domains {
|
||||
// Only configured names, never arbitrary Host input or unknown scope.
|
||||
if !config
|
||||
.vhosts
|
||||
.iter()
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// Pull-friendly JSON telemetry: a compact chart snapshot plus every numeric
|
||||
// sample that the Prometheus text exporter currently emits. Both formats use
|
||||
// the same collector switches and security boundaries.
|
||||
use super::App;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use serde::Serialize;
|
||||
@@ -13,8 +10,6 @@ use std::{
|
||||
|
||||
#[derive(Default, Serialize)]
|
||||
struct MetricSamples {
|
||||
// Metadata is stored separately because histogram/summary samples have
|
||||
// suffixes (_bucket/_sum/_count) that share one Prometheus TYPE family.
|
||||
types: BTreeMap<String, String>,
|
||||
samples: BTreeMap<String, Vec<Sample>>,
|
||||
}
|
||||
@@ -25,9 +20,6 @@ struct Sample {
|
||||
value: Value,
|
||||
}
|
||||
|
||||
// Read only our own Prometheus exposition, never an untrusted remote payload.
|
||||
// Preserve large u64 counters exactly; JSON cannot represent NaN or infinity,
|
||||
// so these values become null rather than breaking the whole API response.
|
||||
fn sample_value(raw: &str) -> Value {
|
||||
if let Ok(value) = raw.parse::<u64>() {
|
||||
return json!(value);
|
||||
@@ -41,8 +33,6 @@ fn sample_value(raw: &str) -> Value {
|
||||
.map_or(Value::Null, |value| json!(value))
|
||||
}
|
||||
|
||||
// Prometheus label escaping: \\, \", \n. Scan the quoted value rather than
|
||||
// splitting on commas (a configured label may contain commas or quotes).
|
||||
fn parse_labels(raw: &str) -> Option<BTreeMap<String, String>> {
|
||||
let bytes = raw.as_bytes();
|
||||
let mut pos = 0;
|
||||
@@ -145,8 +135,6 @@ fn counts(total: usize, enabled: usize) -> Value {
|
||||
json!({"total": total, "enabled": enabled, "disabled": total - enabled})
|
||||
}
|
||||
|
||||
// A small, field-stable projection that an external dashboard can consume
|
||||
// without parsing metric families or knowing RustProxy's widget layout.
|
||||
fn percentage(part: u64, total: u64) -> Option<f64> {
|
||||
(total > 0).then(|| part as f64 * 100.0 / total as f64)
|
||||
}
|
||||
@@ -399,9 +387,6 @@ fn snapshot(app: &App) -> Value {
|
||||
.map(|stream| {
|
||||
let live = app.stream_metrics.get(&stream.id).map(|m| {
|
||||
let view = m.view();
|
||||
// The dashboard's full stream view includes configured backend
|
||||
// socket addresses and health internals. Metrics consumers only
|
||||
// need counters/status, never infrastructure addresses.
|
||||
let backends = view
|
||||
.backends
|
||||
.iter()
|
||||
@@ -494,8 +479,6 @@ fn snapshot(app: &App) -> Value {
|
||||
.unwrap_or_default()
|
||||
.as_millis() as u64;
|
||||
|
||||
// Split the JSON builders: a single giant json! macro would exceed the
|
||||
// default macro recursion depth on supported stable Rust toolchains.
|
||||
let requests = json!({
|
||||
"total": metrics.requests, "completed_total": metrics.completed,
|
||||
"active": metrics.active, "errors_total": metrics.errors,
|
||||
@@ -599,7 +582,6 @@ fn snapshot(app: &App) -> Value {
|
||||
"listeners_active": app.active_listeners.len()
|
||||
}
|
||||
});
|
||||
// Share the exact same computed summary between the full and small APIs.
|
||||
detail["summary"] = summary_from_snapshot(&detail, app.metrics.summary_rates());
|
||||
detail
|
||||
}
|
||||
@@ -621,8 +603,6 @@ pub fn summary_response(app: &App) -> Response {
|
||||
|
||||
pub fn payload(app: &App) -> Value {
|
||||
let mut result = snapshot(app);
|
||||
// Use one exporter implementation, so new Prometheus families automatically
|
||||
// appear here without implementing the same counters a second time.
|
||||
result["prometheus"] = json!(parse_exposition(&super::render(app)));
|
||||
result
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ pub struct Settings {
|
||||
pub listen: SocketAddr,
|
||||
pub path: String,
|
||||
pub allowed_cidrs: Vec<String>,
|
||||
/// Only a variable NAME is persisted; its value is never in config/API.
|
||||
pub bearer_token_env: Option<String>,
|
||||
/// Allow clients already matched by `allowed_cidrs` to scrape without a bearer token.
|
||||
/// Intended only for private/trusted monitoring networks.
|
||||
pub allow_trusted_network_without_token: bool,
|
||||
pub include_system: bool,
|
||||
pub include_vhosts: bool,
|
||||
@@ -99,9 +96,6 @@ impl Settings {
|
||||
"metrics: token environment variable must use A-Z, 0-9, underscore"
|
||||
);
|
||||
}
|
||||
// Runtime checks a generated credential (stored in SQLite) or the
|
||||
// legacy environment variable. Without either, scrapes fail closed.
|
||||
// Non-loopback HTTP still needs a private network/TLS tunnel.
|
||||
Ok(())
|
||||
}
|
||||
pub fn restart_differs(&self, other: &Self) -> bool {
|
||||
@@ -140,12 +134,10 @@ pub fn router(app: Arc<App>, token: Option<Zeroizing<String>>) -> Router {
|
||||
async fn scrape(State(exporter): State<Arc<Exporter>>, request: Request) -> Response {
|
||||
let config = exporter.app.config.load_full();
|
||||
let settings = &config.envelope.config.prometheus;
|
||||
// JSON is a sibling of the configured path, with identical transport auth.
|
||||
let json_path = format!("{}.json", settings.path);
|
||||
let wants_json = request.uri().path() == json_path.as_str();
|
||||
let summary_path = format!("{}.summary.json", settings.path);
|
||||
let wants_summary = request.uri().path() == summary_path.as_str();
|
||||
// Revocation is immediate even when changing bind/credentials needs restart.
|
||||
if !settings.enabled
|
||||
|| settings.restart_differs(&exporter.app.active_prometheus)
|
||||
|| (request.uri().path() != settings.path && !wants_json && !wants_summary)
|
||||
|
||||
@@ -8,8 +8,6 @@ mod tests {
|
||||
settings.validate().unwrap();
|
||||
settings.enabled = true;
|
||||
settings.listen = "0.0.0.0:9191".parse().unwrap();
|
||||
// With generated tokens validation permits remote binds; without a
|
||||
// configured credential the exporter itself returns 401, never 200.
|
||||
assert!(settings.validate().is_ok());
|
||||
settings.bearer_token_env = Some("RUST_PROXY_METRICS_TOKEN".into());
|
||||
settings.validate().unwrap();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// Only configured Web Service IDs and bounded enumerated classes/reasons are labels.
|
||||
fn render_web_php(snapshot: &crate::config::Snapshot, f: &mut Families) {
|
||||
use crate::web_server::metrics::PHP_FAILURE_NAMES;
|
||||
let config = &snapshot.envelope.config;
|
||||
|
||||
Reference in new issue
Block a user