DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Rust (Actix-web) Application with Vigilmon

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
}
Enter fullscreen mode Exit fullscreen mode

This health endpoint:

  • Returns 200 OK with {"status": "ok"} when the database is reachable
  • Returns 503 Service Unavailable when the DB is down
  • Is perfect for Vigilmon to poll

Setting Up Vigilmon

  1. Sign up at vigilmon.online — free tier available
  2. Click Add Monitor
  3. Set URL to https://your-actix-app.com/health
  4. Set interval: 1 minute
  5. Enable multi-region checks for global coverage
  6. 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));
    // ...
}
Enter fullscreen mode Exit fullscreen mode

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)