Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

How to Monitor Your Crystal/Lucky Framework Application with Vigilmon

How to Monitor Your Crystal/Lucky Framework Application with Vigilmon Crystal and the Lucky web framework give you Ruby-like syntax with C-level performance. But fast code still needs uptime monitoring. This guide show

How to Monitor Your Crystal/Lucky Framework Application with Vigilmon

Crystal and the Lucky web framework give you Ruby-like syntax with C-level performance. But fast code still needs uptime monitoring. This guide shows you how to set up production monitoring for your Crystal/Lucky app with Vigilmon.

Why Monitor a Crystal App Externally?

Crystal compiles to native binaries with no runtime overhead. But your app can still go down:

  • Segfault or unhandled exception crashes the process
  • Database connection pool exhaustion
  • Memory leak in a C extension
  • Reverse proxy (nginx/Caddy) misconfiguration after a deploy
  • Certificate expiry

External monitoring catches all of these — Vigilmon checks your actual HTTP endpoint from outside, exactly as users do.

What Vigilmon Monitors

  • HTTP uptime — checks your Lucky app's public URL every minute
  • Response time — tracks how fast pages load across multiple regions
  • SSL/TLS expiry — alerts 30 days before your certificate expires
  • Status codes — detects 500 errors, redirect loops, or unexpected responses
  • Heartbeat checks — for Lucky background jobs (e.g., periodic tasks)

Step 1: Add a Health Check Endpoint

First, add a lightweight health route to your Lucky app:

# src/actions/health_check/show.cr
class HealthCheck::Show < Lucky::Action
  get "/health" do
    plain_text "OK"
  end
end

This route bypasses your app's auth pipeline and returns a simple 200 response.

Test it locally:

curl http://localhost:5000/health
# OK

Step 2: Add Vigilmon Monitor

  1. Sign up at vigilmon.online
  2. Click New Monitor
  3. Enter your Lucky app's health URL: https://yourapp.com/health
  4. Set check interval: 1 minute
  5. Add alert contacts (email, Slack, PagerDuty)
  6. Save

Vigilmon immediately starts checking from multiple geographic regions.

Step 3: SSL Certificate Monitoring

Add a second monitor for SSL:

  1. Click New Monitor → select SSL Certificate
  2. Enter your domain: yourapp.com
  3. Set expiry threshold: 30 days

You'll get an alert with enough time to renew before expiry causes downtime.

Step 4: Monitor Background Jobs (Heartbeat)

If your Lucky app runs periodic tasks — cron-style jobs using spawn or an external scheduler — add a heartbeat monitor:

  1. In Vigilmon, create a Heartbeat Monitor
  2. Copy the unique ping URL (e.g., https://vigilmon.online/ping/abc123)
  3. In your scheduled task, ping that URL each time it runs:
# In your periodic job
def run
  # ... your job logic ...

  # Ping Vigilmon on success
  HTTP::Client.get("https://vigilmon.online/ping/your-heartbeat-id")
end

If your job fails or stops running, Vigilmon detects the missed heartbeat and alerts you.

Step 5: Set Up Alerting

Vigilmon supports multiple alert channels:

  • Email — instant notification to your team
  • Slack — posts to your ops channel
  • PagerDuty — for on-call rotation
  • Webhooks — any custom endpoint

For Lucky apps in production, set up Slack + email at minimum.

Checking Your Monitor Dashboard

After setup, your Vigilmon dashboard shows:

  • Uptime percentage over 24h / 7d / 30d
  • Response time graph with regional breakdown
  • Incident history — every outage logged with start/end time
  • SSL expiry countdown

Why Crystal/Lucky Apps Need External Monitoring

Lucky's type-safe approach catches many bugs at compile time, but production failures still happen. Common Crystal production issues:

Failure Mode Vigilmon Detects?
Process crash (SIGSEGV) Yes — HTTP check fails
nginx proxy timeout Yes — response time spike + timeout
Database connection error Yes — 500 response code
OOM kill Yes — no response
SSL expiry Yes — certificate monitor
Deploy broke routing Yes — immediate HTTP check failure

Summary

Setting up Vigilmon for your Crystal/Lucky app takes under 5 minutes:

  1. Add /health endpoint to your Lucky app
  2. Add HTTP uptime monitor in Vigilmon
  3. Add SSL certificate monitor
  4. Add heartbeat monitors for background jobs
  5. Configure Slack/email alerts

Vigilmon handles external monitoring so you know immediately when something breaks — whether it's a deploy gone wrong, a process crash, or a cert about to expire.

Monitor your Crystal/Lucky app in production with Vigilmon — free to start.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.