https://github.com/giangndm/metrics-dashboard-rs
Zero-config dashboard with metrics-rs
https://github.com/giangndm/metrics-dashboard-rs
dashboard metric-rs rust zero-config
Last synced: 7 months ago
JSON representation
Zero-config dashboard with metrics-rs
- Host: GitHub
- URL: https://github.com/giangndm/metrics-dashboard-rs
- Owner: giangndm
- License: mit
- Created: 2023-12-02T14:02:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-26T17:04:30.000Z (over 1 year ago)
- Last Synced: 2025-10-16T01:04:31.876Z (9 months ago)
- Topics: dashboard, metric-rs, rust, zero-config
- Language: Rust
- Homepage:
- Size: 175 KB
- Stars: 9
- Watchers: 1
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# metrics-dashboard-rs
[](https://crates.io/crates/metrics-dashboard)
[](https://docs.rs/metrics-dashboard)
[](https://github.com/giangndm/metrics-dashboard-rs/actions)
This crate provide simple auto-generate dashboard for [metric-rs](https://crates.io/crates/metrics) crate.
## Screenshot

## How to use
* run `cargo add metrics-dashboard`
* include into poem webserver like bellow:
```rust
use std::time::Duration;
use metrics_dashboard::build_dashboard_route;
use metrics::{describe_counter, increment_counter};
use poem::{
get, handler, listener::TcpListener, middleware::Tracing, web::Path, EndpointExt, Route, Server,
};
#[handler]
fn hello(Path(name): Path) -> String {
format!("hello: {name}")
}
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
if std::env::var_os("RUST_LOG").is_none() {
std::env::set_var("RUST_LOG", "poem=debug");
}
tracing_subscriber::fmt::init();
let dashboard_options = DashboardOptions {
custom_charts: vec![
ChartType::Line {
metrics: vec![
"demo_live_time".to_string(),
"demo_live_time_max".to_string(),
],
desc: Some("Demo metric line".to_string()),
}
],
include_default: true,
};
let app = Route::new()
.at("/hello/:name", get(hello))
.nest("/dashboard/", build_dashboard_route())
.with(Tracing);
tokio::spawn(async move {
describe_counter!("demo_metric1", "Demo metric1");
loop {
tokio::time::sleep(Duration::from_secs(1)).await;
increment_counter!("demo_metric1");
}
});
tokio::spawn(async move {
describe_counter!("demo_metric2", "Demo metric2");
loop {
tokio::time::sleep(Duration::from_secs(1)).await;
increment_counter!("demo_metric2");
}
});
Server::new(TcpListener::bind("0.0.0.0:3000"))
.name("hello-world")
.run(app)
.await
}
```
## License
Licensed under ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the MIT license, without any additional terms or conditions.
See [CONTRIBUTING.md](CONTRIBUTING.md).