Code Monkey home page Code Monkey logo

dogwatch's Introduction

DogWatch

A DSL to create Datadog monitors

This gem is designed to provide a simple method for creating Datadog monitors in Ruby.

Installation

Add this line to your application's Gemfile:

gem 'dogwatch'

And then execute:

$ bundle exec dogwatch create [--dogfile=DOGFILE] [--api_key=API KEY] [--app_key=APP KEY]

Or install it yourself as:

$ gem install dogwatch

Credentials

Datadog API credentials are required.

Generate both an api key and an app key and either place them in a file named ~/.dogwatch/credentials or pass them via the command line.

A sample credentials file is provided in the example directory.

In order to generate these keys, log into your Datadog account. From there, click on 'Integrations->APIs'. Keep in mind, your org may be allowed only five API Keys.

Usage

DogWatch is a thin DSL over the Datadog ruby client that handles generating Datadog monitors.

The following is an example of a Dogfile:

DogWatch.monitor do
  ## Create a new monitor - monitor name is REQUIRED
  monitor 'MONITOR NAME' do
    type :metric_alert # REQUIRED: One of [:metric_alert | :service_check | :event_alert]
    query 'time_aggr(time_window):space_aggr:metric{tags} [by {key}] operator' # REQUIRED
    message 'MESSAGE'
    tags %w(A list of tags to associate with your monitor)

    options do
      silenced '*': nil
      notify_no_data false
      no_data_timeframe 3
      timeout_h 99
      evaluation_delay 120
      renotify_interval 60
      escalation_message 'oh snap'
      include_tags true
    end
  end
end

Queries are the combination of several items including a time aggregator (over a window of time), space aggregator (avg, sum, min, or max), a set of tags and an optional order by, and an operator.

From the Datadog documentation:

time_aggr(time_window):space_aggr:metric{tags} [by {key}] operator

An example of a query:

avg(last_15m):avg:system.disk.used{region:us-east-1,some-tag:some-tag-value,device:/dev/xvdb} by {cluster} * 100 > 55

Monitors that already exist are matched by name and updated accordingly. If the name isn't matched exactly, DogWatch assumes you want a new monitor.

A sample Dogfile is provided in the example directory.

For a full list of options and a description of each parameter, see Datadog's API documentation.

TO DO

  • More descriptive errors
  • Better error handling if a monitor fails local validation

dogwatch's People

Contributors

dgreene-r7 avatar erran avatar erran-r7 avatar fmitchell-r7 avatar irabinovitch avatar udangel-r7 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.