use prometheus::{
Registry, Counter, Gauge, Histogram,
IntCounterVec, GaugeVec, HistogramVec,
};
use lazy_static::lazy_static;
lazy_static! {
pub static ref REGISTRY: Registry = Registry::new();
pub static ref SECURITY_ALERTS_TOTAL: IntCounterVec = IntCounterVec::new(
opts!("security_alerts_total", "Total number of security alerts"),
&["severity"]
).unwrap();
pub static ref RISK_SCORE: Gauge = Gauge::new(
"security_risk_score",
"Current security risk score"
).unwrap();
pub static ref ALERT_RESOLUTION_TIME: HistogramVec = HistogramVec::new(
histogram_opts!("alert_resolution_seconds", "Time to resolve alerts"),
&["severity"]
).unwrap();
pub static ref MODEL_ACCURACY: Gauge = Gauge::new(
"model_accuracy",
"Current model accuracy"
).unwrap();
pub static ref PREDICTION_LATENCY: Histogram = Histogram::new(
histogram_opts!("prediction_latency_seconds", "Time to make predictions")
).unwrap();
pub static ref MEMORY_USAGE: Gauge = Gauge::new(
"memory_usage_bytes",
"Current memory usage in bytes"
).unwrap();
pub static ref CPU_USAGE: Gauge = Gauge::new(
"cpu_usage_percent",
"Current CPU usage percentage"
).unwrap();
}
pub fn register_metrics() {
REGISTRY.register(Box::new(SECURITY_ALERTS_TOTAL.clone())).unwrap();
REGISTRY.register(Box::new(RISK_SCORE.clone())).unwrap();
REGISTRY.register(Box::new(ALERT_RESOLUTION_TIME.clone())).unwrap();
REGISTRY.register(Box::new(MODEL_ACCURACY.clone())).unwrap();
REGISTRY.register(Box::new(PREDICTION_LATENCY.clone())).unwrap();
REGISTRY.register(Box::new(MEMORY_USAGE.clone())).unwrap();
REGISTRY.register(Box::new(CPU_USAGE.clone())).unwrap();
}