How to Monitor Your Rust (Actix-web) Application with Vigilmon
Rust and Actix-web deliver some of the fastest HTTP throughput of any web framework. But speed doesn't equal invincibility — servers go down, databases disconnect, and deploys introduce regressions. External uptime monitoring is essential for any production Rust service.
In this guide, we'll set up a health check endpoint in your Actix-web app and connect it to Vigilmon for continuous monitoring.
Adding a Health Check to Actix-web
Actix-web makes it easy to add a health endpoint:
use actix_web::{web, App, HttpServer, HttpResponse, middleware};
use serde::Serialize;
#[derive(Serialize)]
struct HealthResponse {
status: String,
db: String,
}
async fn health_check(pool: web::Data<PgPool>) -> HttpResponse {
match sqlx::query("SELECT 1")
.fetch_one(pool.get_ref())
.await
{
Ok(_) => HttpResponse::Ok().json(HealthResponse {
status: "ok".to_string(),
db: "connected".to_string(),
}),
Err(e) => HttpResponse::ServiceUnavailable().json(HealthResponse {
status: "error".to_string(),
db: e.to_string(),
}),
}
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let pool = PgPool::connect(&std::env::var("DATABASE_URL").unwrap())
.await
.unwrap();
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(pool.clone()))
.route("/health", web::get().to(health_check))
// ... other routes
})
.bind("0.0.0.0:8080")?
.run()
.await
}
This health endpoint:
- Returns
200 OKwith{"status": "ok"}when the database is reachable - Returns
503 Service Unavailablewhen the DB is down - Is perfect for Vigilmon to poll
Setting Up Vigilmon
- Sign up at vigilmon.online — free tier available
- Click Add Monitor
- Set URL to
https://your-actix-app.com/health - Set interval: 1 minute
- Enable multi-region checks for global coverage
- Configure alerts (email, Slack, PagerDuty, webhook)
Monitoring Axum Instead of Actix?
If you're using Axum (the other popular Rust web framework), the pattern is nearly identical:
use axum::{
routing::get,
Router,
Json,
http::StatusCode,
};
use serde::Serialize;
#[derive(Serialize)]
struct Health {
status: &'static str,
}
async fn health() -> (StatusCode, Json<Health>) {
(StatusCode::OK, Json(Health { status: "ok" }))
}
#[tokio::main]
async fn main() {
let app = Router::new().route("/health", get(health));
// ...
}
What to Monitor in Production Rust Services
| Endpoint | What it checks |
|---|---|
/health |
App is running, DB connected |
/api/v1/status |
Business logic is functional |
| Main homepage or API root | Full stack is serving traffic |
Alerting and On-Call
Vigilmon can alert you via:
- Email — instant notification
- Webhooks — connect to PagerDuty, Opsgenie, or any REST endpoint
- Slack — post to your on-call channel
Set a 2-minute confirmation period to avoid alert fatigue from transient blips.
Conclusion
Your Rust service is blazing fast — but it still needs watching. Vigilmon gives you production-grade uptime monitoring with a free tier, multi-region checks, and instant alerts.
Start monitoring your Rust services at vigilmon.online.
Top comments (0)