Class: Hawkular::Metrics::Client::Gauges

Inherits:
Metrics
  • Object
show all
Defined in:
lib/hawkular/metrics/metric_api.rb

Overview

Class that interacts with “gauge” metric types

Instance Method Summary collapse

Methods inherited from Metrics

#create, #encode_params, #get, #get_data, #get_data_by_tags, #push_data, #query, #raw_data, #update_tags

Constructor Details

#initialize(client) ⇒ Gauges

Returns a new instance of Gauges

Parameters:



248
249
250
# File 'lib/hawkular/metrics/metric_api.rb', line 248

def initialize(client)
  super(client, 'gauge', 'gauges')
end

Instance Method Details

#get_periods(id, starts: nil, ends: nil, threshold: nil, operation: nil) ⇒ Object

Retrieve time ranges when given gauge matches given operation and threshold

Examples:

Get time periods when metric “gauge1” was under 10 in past 4 hours

before4h = client.now - (4 * 60 * 60 * 1000)
client.gauges.get_periods("gauge1", starts: before4h, threshold: 10, operation: "lte")

Parameters:

  • id (String)

    gauge ID

  • starts (Integer)

    timestamp (default now - 8h)

  • ends (Integer)

    timestamp (default now)

  • threshold (Numeric)
  • operation (String)

    A comparison operation to perform between values and the threshold. Supported operations include “ge”, “gte”, “lt”, “lte”, and “eq”



262
263
264
265
# File 'lib/hawkular/metrics/metric_api.rb', line 262

def get_periods(id, starts: nil, ends: nil, threshold: nil, operation: nil)
  params = { start: starts, end: ends, threshold: threshold, op: operation }
  @client.http_get("/#{@resource}/#{ERB::Util.url_encode(id)}/periods?" + encode_params(params))
end