A comprehensive metrics and monitoring framework for Axum applications, providing real-time performance tracking, memory monitoring, and route analytics with a beautiful web dashboard.
Dashboard is a powerful monitoring library designed specifically for Rust web applications built with the Axum framework. It provides detailed insights into your application's performance, memory usage, and route behavior through an intuitive web interface with real-time updates.
- Live system metrics (CPU, memory usage)
- Real-time route performance tracking
- WebSocket-based dashboard updates
- Process-specific monitoring
- Route call statistics with timing information
- Memory allocation and deallocation tracking
- Sliding window averages for performance trends
- Success/error rate monitoring
- Custom global allocator for precise tracking
- Memory delta tracking per request
- Peak memory usage monitoring
- Allocation size categorization
- Simple middleware integration
Procedural macros for automatic instrumentation- Minimal configuration required
- Non-intrusive design
- Save and load metrics data
- Historical data analysis
- Selective data deletion
- Automatic shutdown data saving
- Modern web interface
- Real-time charts and graphs
- Route blacklisting capabilities
- Responsive design
Add the following to your Cargo.toml
:
[dependencies]
dashboard = "0.1.0"
use axum::{Router, routing::get};
use dashboard::{create_metrics_router, auto_save_metrics_on_shutdown, instrument_routes};
#[tokio::main]
async fn main() {
dashboard::auto_save_metrics_on_shutdown();
let app = Router::new()
.route("/", get(|| async { "Hello, World!" }))
.route("/api/users", get(get_users));
let app = instrument_routes(app);
let app = app.merge(dashboard::create_metrics_router());
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
async fn get_users() -> &'static str {
"Users endpoint"
}
Once your application is running, visit http://localhost:3000/metrics
to access the monitoring dashboard.
The Dashboard framework consists of several key components:
- Global State Management: Thread-safe storage for metrics data
- Memory Tracking: Custom allocator for precise memory monitoring
- Route Middleware: Automatic request/response tracking
- WebSocket Server: Real-time data streaming to the dashboard
- Persistence Layer: Data saving and loading capabilities
- Route Tracking Macros: Automatic instrumentation for individual routes
- Middleware Macros: Custom middleware generation
- Bulk Instrumentation: Automatic tracking for entire routers
- Real-time Interface: Live updating charts and metrics
- Data Visualization: Interactive graphs using Chart.js
- Control Panel: Route blacklisting and data management
- Responsive Design: Works on desktop and mobile devices
.
├── dashboard
│ └── src
│ ├── globals.rs # some global variables
│ ├── lib.rs # core library implementation
│ └── models
│ └── ... # models reexported in library
├── examples # Usage examples
│ └── basic_example # Basic integration example
└── ui
└── index.html # Web dashboard