Class: CachetMetrics

Inherits:
CachetClient show all
Defined in:
lib/cachet.rb

Overview

Inherits CachetClient and handles all Metrics API Calls

Constant Summary

Constants inherited from CachetClient

CachetClient::INCIDENT_FIXED, CachetClient::INCIDENT_IDENTIFIED, CachetClient::INCIDENT_INVESTIGATING, CachetClient::INCIDENT_SCHEDULED, CachetClient::INCIDENT_WATCHING, CachetClient::STATUS_MAJOR_OUTAGE, CachetClient::STATUS_OPERATIONAL, CachetClient::STATUS_PARTIAL_OUTAGE, CachetClient::STATUS_PERFORMANCE_ISSUES, CachetClient::VERSION

Instance Method Summary collapse

Methods inherited from CachetClient

#initialize, #ping, #request

Constructor Details

This class inherits a constructor from CachetClient

Instance Method Details

#create(options) ⇒ Object

Create Metric.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :name (string)

    Required Metric name

  • :suffix (string)

    Required Measurments in

  • :description (string)

    Required Description of what is measured

  • :default_value (int)

    Required The default value for points

  • :display_chart (int)

    Required Whether to display the chart on the status page

Returns:

  • object



324
325
326
327
328
# File 'lib/cachet.rb', line 324

def create(options)
  request method:  :post,
          url:     @base_url + 'metrics',
          payload: options
end

#delete(options) ⇒ Object

Delete a Metric.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :id (string)

    Numeric Metric id

Returns:

  • object



347
348
349
350
# File 'lib/cachet.rb', line 347

def delete(options)
  request method:  :delete,
          url:     @base_url + 'metrics/' + options['id'].to_s
end

#listObject

List all Metrics.

Returns:

  • object



309
310
311
312
# File 'lib/cachet.rb', line 309

def list
  request method:  :get,
          url:     @base_url + 'metrics'
end

#list_id(options) ⇒ Object

List Metric by ID Without Points.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :id (string)

    Numeric Metric id

Returns:

  • object



336
337
338
339
# File 'lib/cachet.rb', line 336

def list_id(options)
  request method:  :get,
          url:     @base_url + 'metrics/' + options['id'].to_s
end

#point_add(options) ⇒ Object

Add Metric Point.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :id (string)

    Numeric Metric id

  • :value (int)

    Required Value to plot on the metric graph

  • :timestamp (string)

    Unix timestamp of the point was measured

Returns:

  • object



371
372
373
374
375
# File 'lib/cachet.rb', line 371

def point_add(options)
  request method:  :post,
          url:     @base_url + 'metrics/' + options['id'].to_s + '/points',
          payload: options
end

#point_delete(options) ⇒ Object

Delete Metric Point.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :id (string)

    Numeric Metric id

  • :point_id (int)

    Required Metric Point id

Returns:

  • object



384
385
386
387
388
# File 'lib/cachet.rb', line 384

def point_delete(options)
  request method:  :delete,
          url:     @base_url + 'metrics/' + options['id'].to_s + '/points/' + options['point_id'].to_s,
          payload: options
end

#point_list(options) ⇒ Object

List Metric Points.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :id (string)

    Numeric Metric id

Returns:

  • object



358
359
360
361
# File 'lib/cachet.rb', line 358

def point_list(options)
  request method:  :get,
          url:     @base_url + 'metrics/' + options['id'].to_s + '/points'
end