How to Monitor StimulusReflex with Vigilmon
StimulusReflex makes Rails apps feel like single-page applications — but when a WebSocket connection drops or a reflex silently fails, your users are left staring at a page that never updates. You won't see a 500 in your logs. You won't see an exception. You just stop getting results.
This tutorial shows you how to set up monitoring for a StimulusReflex app so you catch failures before your users do.
Why monitoring StimulusReflex is different
Standard HTTP uptime checks verify that your Rails server responds to requests. That's necessary — but not sufficient for StimulusReflex apps.
StimulusReflex relies on Action Cable, which uses persistent WebSocket connections. If Action Cable is degraded (Redis connection lost, cable process crashed, connection pool exhausted), your HTTP health check can still return 200 while every reflex silently fails.
The failure modes to watch for:
- HTTP endpoint down — Rails server not responding at all
- Action Cable disconnected — WebSocket upgrade fails or connections drop
- Redis unavailable — Action Cable loses its pub/sub backend
- Reflex timeouts — server-side reflex execution hanging
Step 1: Add a health check endpoint
Add the health_check gem to your Gemfile:
# Gemfile
gem 'health_check'
gem 'redis'
Install and configure:
bundle install
# config/initializers/health_check.rb
HealthCheck.setup do |config|
config.standard_checks = ['database', 'cache', 'redis', 'migrations']
config.full_checks = ['database', 'cache', 'redis', 'migrations']
end
Mount it in your routes:
# config/routes.rb
Rails.application.routes.draw do
mount HealthCheck::Engine, at: '/health'
end
Verify it works:
curl http://localhost:3000/health
# healthy
Step 2: Add a StimulusReflex-specific health endpoint
Create a dedicated endpoint that checks Action Cable and Redis together:
# app/controllers/health_controller.rb
class HealthController < ApplicationController
skip_before_action :authenticate_user!, raise: false
def cable
redis = Redis.new(url: ENV.fetch('REDIS_URL', 'redis://localhost:6379'))
redis.ping
render json: {
status: 'ok',
redis: 'connected',
action_cable: 'available'
}, status: :ok
rescue Redis::CannotConnectError => e
render json: {
status: 'error',
redis: 'unavailable',
message: e.message
}, status: :service_unavailable
end
end
# config/routes.rb
Rails.application.routes.draw do
mount HealthCheck::Engine, at: '/health'
get '/health/cable', to: 'health#cable'
end
Test it:
curl http://localhost:3000/health/cable
# {"status":"ok","redis":"connected","action_cable":"available"}
Step 3: Set up Vigilmon monitoring
With both health endpoints live, add them to Vigilmon:
- Sign up at vigilmon.online
- Click New Monitor → HTTP
- Add your main health check:
https://yourdomain.com/health- Check interval: every 1 minute
- Expected status: 200
- Add your cable health check:
https://yourdomain.com/health/cable- Check interval: every 1 minute
- Expected status: 200
- Expected body:
"status":"ok"
You now have two monitors: one for general Rails health, one specifically for the Action Cable and Redis stack that StimulusReflex depends on.
Step 4: Set up Slack alerting
When a monitor fails, you want to know immediately:
- In Vigilmon, go to Settings → Integrations → Slack
- Click Connect Slack and authorize the workspace
- Choose the channel (e.g.
#alertsor#ops) - Click Save
Now open any monitor and enable Alert on failure with your Slack integration. Vigilmon will send a message within seconds of detecting a failure, including which check failed and the last known status.
Step 5: Key metrics to watch
Beyond uptime, configure these thresholds in Vigilmon:
| Metric | Warning | Critical |
|--------|---------|----------|
| HTTP response time | > 500ms | > 2000ms |
| /health/cable response time | > 300ms | > 1000ms |
| Uptime (7-day) | < 99.9% | < 99% |
Response time spikes on your cable health endpoint often indicate Redis latency before a full outage occurs — catching them early lets you scale Redis or flush connection pools before users notice.
Step 6: Public status page
Add a public status page so users can self-serve during incidents:
- In Vigilmon, go to Status Pages → New Status Page
- Add both monitors
- Set a custom domain (e.g.
status.yourdomain.com) - Publish
Your status page will automatically reflect live monitor state — green when all checks pass, degraded or outage when any fail.
Conclusion
StimulusReflex moves server-side rendering over WebSockets, which means standard HTTP uptime monitoring only covers half the picture. With Vigilmon, you get:
- HTTP uptime monitoring for the Rails layer
- Redis and Action Cable health checks for the WebSocket layer
- Slack alerts the moment either layer degrades
- A public status page for transparent incident communication
Sign up at vigilmon.online and have full StimulusReflex monitoring running in under 30 minutes.