Blog

Checking Your Application’s Heartbeat

Today, Awexome Labs released version 0.1.0 of our new gem HasHeartbeat. This Rubygem can be used by Ruby on Rails developers to add a lightweight heartbeat endpoint to their new and existing applications. Check out the gem source, now.

We extracted HasHeartbeat from work we’ve been using in production applications built internally and for clients over the past year. The premise is simple: add a route/endpoint/controller-action to your application that can be struck from a simple monitoring service that tells you basic things you need to know at a glance:

  • Is my application up and running?
  • Can my application connect to its database?

HasHeartbeat adds a /heartbeat path to your application, which responds with a 200 OK or 500 Error HTTP Status, as well as a helpful text response that is easily parsed by your favorite monitoring service. At your option, you can configure the heartbeat action to attempt to load a model from your database to verify that your application is successfully communicating with your database.

In practice, we’ve configured New Relic, Codebase, Pingdom, and client proprietary monitoring services against this feature set, striking the /heartbeat path on regular intervals and connecting that response to monitoring. It’s been a life-saver for tracking uptime, as well as providing detailed transparency of application availability to our clients — without forcing us to expose the internal workings of our hosting solutions.

Dropping in a working heartbeat endpoint is now as simple as adding “has_heartbeat” to your Gemfile.

Learn more about HasHeartbeat on github.
Check information on RubyGems.