Class: Hawkular::Metrics::Client::Counters

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

Overview

Class that interacts with “counter” 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) ⇒ Counters

Returns a new instance of Counters

Parameters:



271
272
273
# File 'lib/hawkular/metrics/metric_api.rb', line 271

def initialize(client)
  super(client, 'counter', 'counters')
end

Instance Method Details

#get_rate(id, starts: nil, ends: nil, bucket_duration: nil) ⇒ Array[Hash]

Retrieve metric rate points

Parameters:

  • id (String)

    metric definition id

  • starts (Integer)

    optional timestamp (default now - 8h)

  • ends (Integer)

    optional timestamp (default now)

  • bucket_duration (String)

    optional interval (default no aggregation)

Returns:

  • (Array[Hash])

    rate points



282
283
284
285
286
287
288
289
# File 'lib/hawkular/metrics/metric_api.rb', line 282

def get_rate(id, starts: nil, ends: nil, bucket_duration: nil)
  path = "/#{@resource}/#{ERB::Util.url_encode(id)}/rate"
  path << '/stats' unless bucket_duration.nil? || @legacy_api
  params = { start: starts, end: ends, bucketDuration: bucket_duration }
  resp = @client.http_get(path + '?' + encode_params(params))
  # API returns no content (empty Hash) instead of empty array
  resp.is_a?(Array) ? resp : []
end