Module: Librato::Metrics
- Extended by:
- SingleForwardable
- Defined in:
- lib/librato/metrics.rb,
lib/librato/metrics/queue.rb,
lib/librato/metrics/errors.rb,
lib/librato/metrics/simple.rb,
lib/librato/metrics/collect.rb,
lib/librato/metrics/version.rb,
lib/librato/metrics/persistence/test.rb,
lib/librato/metrics/persistence/direct.rb
Overview
Metrics provides a simple wrapper for the Metrics web API. Some of the methods Metrics provides will be documented below. Others are delegated to Simple and will be documented there.
Defined Under Namespace
Modules: Persistence Classes: AgentInfoMissing, Collect, CredentialsMissing, MetricsError, NoMetricsQueued, Queue, Simple
Constant Summary collapse
- TYPES =
[:counter, :gauge]
- VERSION =
"0.4.0"
Class Method Summary collapse
-
.fetch(metric, options = {}) ⇒ Object
Query metric data.
-
.list(options = {}) ⇒ Object
List currently existing metrics.
Class Method Details
.fetch(metric, options = {}) ⇒ Object
Query metric data
A full list of query parameters can be found in the API documentation: http://dev.librato.com/v1/get/gauges/:name
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/librato/metrics.rb', line 62 def self.fetch(metric, ={}) query = .dup if query[:start_time].respond_to?(:year) query[:start_time] = query[:start_time].to_i end if query[:end_time].respond_to?(:year) query[:end_time] = query[:end_time].to_i end unless query.empty? query[:resolution] ||= 1 end response = connection.get(:path => "v1/metrics/#{metric}", :query => query, :expects => 200) parsed = MultiJson.decode(response.body) # TODO: pagination support query.empty? ? parsed : parsed["measurements"] end |
.list(options = {}) ⇒ Object
List currently existing metrics
89 90 91 92 93 94 95 |
# File 'lib/librato/metrics.rb', line 89 def self.list(={}) query = {} query[:name] = [:name] if [:name] offset = 0 path = "v1/metrics" Collect.paginated_metrics connection, path, query end |