Git Product home page Git Product logo

health_monitor's Introduction

RtHealthMonitor

Gem Version

Get information about your applications health status easily.

As soon as the gem is configured and your application is running, you can access a health monitor status, e.g. http://example.com/health_monitor

This would produce the following output:

{
  "status": "down",
  "name": "my service",
  "simple": [
    {
      "status": "up",
      "name": "MySQL",
      "time": 0.2758502960205078
    },
    {
      "status": "up",
      "name": "Memcached",
      "time": 1.4078617095947266
    }
  ],
  "service": [
    {
      "status": "up",
      "name": "another service",
      "info": {
        "simple": [
          {
            "status": "up",
            "name": "MongoDB",
            "time": 6.000041961669922
          },
          {
            "status": "up",
            "name": "MySQL",
            "time": 0
          }
        ]
      },
      "time": 23.989439010620117
    }
  ]
}

Installation

Add this line to your application's Gemfile:

gem 'rt_health_monitor', require: 'health_monitor'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rt_health_monitor

Configuration

Rails

Add the middleware to your Rails configuration

module <ApplicationName>
  class Application < Rails::Application
    config.middleware.use ::HealthMonitorMiddleware, "your_application_name"
  end
end

Sinatra

Add the middleware to your config.ru

use HealthMonitorMiddleware, "your_application_name"

Padrino

Add the middleware to config/apps.rb

Padrino.use(HealthMonitorMiddleware, "your_application_name")

Usage

Put the following configurations some place where they are loaded on startup, like config/initializer/health_monitor_initializer.rb

Simple monitors

These can be used to monitor a database connection or anything that can be in two states.

Example:

HealthMonitorMiddleware.add("simple", name: "MySQL") do
  ActiveRecord::Base.connected?
end

Service monitors

These can be used to monitor another service that is also using this gem. The block needs to return the result of the /health_monitor endpoint of the other service:

HealthMonitorMiddleware.add("service", name: 'some_service_name') do
  RestClient.get("https://some-service.example.com/health_monitor")
end

Sidekiq Health Check Task

A task for performing a Sidekiq health check is also included. To use that, just add the following line to your Rakefile

require "health_monitor/rake_task"

You must have an environment task in your Rakefile which loads the environment. Rails already provides such a task.

A simple environment task looks like this:

task :environment do
  require_relative "./config/environment" if File.exists?("./config/environment")
end

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/runtastic/rt_health_monitor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

health_monitor's People

Contributors

goltergaul avatar kmpzr avatar nilsding avatar thewudu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.