Git Product home page Git Product logo

updown-ruby's Introduction

Updown

A Ruby wrapper and CLI for the updown.io API

Installation

Add this line to your application's Gemfile:

gem 'updown'

Or install it yourself as:

$ gem install updown

Configuration

Set your API key

# config/initializers/updown.rb
Updown.configure do |config|
  config.api_key = 'your_api_key'
end
# or
Updown.configuration.api_key = 'your_api_key'

Or set the UPDOWN_API_KEY environment variable

Find your API key in your settings page.

Usage

List all your checks:

Updown::Check.all
# => [<Updown::Check>, <Updown::Check>, … ]

Retrieve a specific check:

Updown::Check.get check_token
# => <Updown::Check>

# include performance metrics for the last hour
check = Updown::Check.get check_token, metrics: true
check.metrics
# => {"apdex": 0.98, "requests": { … }, "timings": { … }}

List downtimes for a specific check (paginated, 100 per call):

check.downtimes
# => [<Updown::Downtime>, <Updown::Downtime>, … ]

check.downtimes page: 2
# => [<Updown::Downtime>]

Get detailed performance metrics for a specific check:

# Default is for last month
check.get_metrics
# => {"apdex": 0.98, "requests": { … }, "timings": { … }}

# Specify time span
check.get_metrics from: 4.hours.ago, to: 2.hours.ago
# => {"apdex": 1, "requests": { … }, "timings": { … }}

# Specify grouping per location (:host) or hour (:time)
check.get_metrics group: :host
# => {
#   "sgp" => {"apdex": 0.82, "host": { city: "Singapore", … }, … },
#   "sfo" => {"apdex": 0.98, "host": { city: "San Francisco", … }, … },
#   "alpha" => {"apdex": 0.98, "host": { city: "Montreal", … }, … },
#   "gra" => {"apdex": 0.92, "host": { city: "Gravelines", … }, … }
# }

Create a new check:

Updown::Check.create 'https://google.com'
# => <Updown::Check>

You can also set any parameters allowed by the API, like enabled, published, period or apdex_t:

Updown::Check.create 'https://google.com', period: 30, published: true
# => <Updown::Check>

In case of validation errors, an Updown::Error will be raised:

Updown::Check.create 'https://google.com', period: 45
# => Updown::Error: URL is already registered (given: "https://google.com"), Period is not included in the list (given: 45)

Update a specific check:

check.update period: 30
# => <Updown::Check>

Delete a specific check:

check.destroy
# => true

Learn more about the API here: https://updown.io/api

Command Line

This gem also comes with an updown shell command. First, configure your API key:

$ updown configure YOUR_API_KEY

See the status of your checks:

$ updown status
 [up]  rjis — https://google.com
[DOWN] bn94 — https://bing.com
 [up]  qwer — http://stackoverflow.com

Open the status page of a check:

$ updown open rjis

Add a new check:

$ updown add https://google.com

Todo

  • Write tests!

Contributing

  1. Fork it ( https://github.com/askehansen/updown-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

MIT

updown-ruby's People

Contributors

askehansen avatar jarthod avatar intrepidd avatar brennana avatar fabienchaynes avatar epistrephein avatar luisdanielroviracontreras avatar

Watchers

James Cloos 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.