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


327
328
329
330
331
# File 'lib/cachet.rb', line 327

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


350
351
352
353
# File 'lib/cachet.rb', line 350

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

#listObject

List all Metrics.

Returns:

  • object


312
313
314
315
# File 'lib/cachet.rb', line 312

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


339
340
341
342
# File 'lib/cachet.rb', line 339

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


374
375
376
377
378
# File 'lib/cachet.rb', line 374

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


387
388
389
390
391
# File 'lib/cachet.rb', line 387

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


361
362
363
364
# File 'lib/cachet.rb', line 361

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