Closed repeatedly closed 11 years ago
Sorry you're running into trouble. Can you give me a code example of what you are trying to do, so I can verify the behavior?
Okay. Reduced code is below:
require 'librato/metrics'
client = Librato::Metrics::Client.new
client.authenticate 'user', 'password'
metric = Librato::Metrics::Collection.paginated_metrics(client.connection, "metrics/metrics1", :source => 'group1-column1')
I got:
/path/to/app/vendor/bundle/ruby/1.9.1/gems/librato-metrics-1.0.4/lib/librato/metrics/collection.rb:19:in `paginated_metrics': undefined method `[]' for nil:NilClass (NoMethodError)
from librato_test.rb:5:in `<main>'
Hmm. Collection
is an internal class and isn't intended to be used directly. Instead try something like this:
require 'librato/metrics'
client = Librato::Metrics::Client.new
client.authenticate 'user', 'password'
client.fetch "metrics1", :sources => ['group1-column1'], :count => 10
Note that #fetch
requires either a start_time
or a count
to return measurements. Here's a few more references.
I don't know how long you've been submitting, but fetching all the data may be a bunch of requests and take a while. To get it all you might try something like:
client.fetch 'mymetric', :sources => ['mysource'], :start_time => 1.year.ago.to_i, :end_time => Time.now
Let me know if this gets you what you need?
Sorry for the delay.
I tried fetch
before paginated_metrics
but fetch
has 100 metrics limitation in response(both count
and start_time
).
Your example also returns same result.
I passed start_time
, end_time
and resolution
but got result has only 100 metrics, not all metric values.
How to get all metric values with fetch
method?
Check last metric time and re-call fetch
method using last metric time as start_time
?
Ah yes, I was mistaken before, it looks like we currently support pagination when listing metrics but we don't when fetching measurements. I can look into adding it for you or you can manually paginate using offset
as described here.
I can look into adding it for you
This is great. Fetch with pagination seems important to use librato as a backend.
Sounds good, I've created #84 for this enhancement - subscribe to that ticket for updates. I'm going to close this ticket in the meantime but feel free to re-open or comment on #84 if you have further thoughts/questions.
Currently, I'm using librato metrics for our service. And I tried to get all values from one metric but paginated_metrics didn't work correctly.
http://dev.librato.com/v1/get/metrics/:name
From API document, response has 'measurements' field, not 'metrics'. Is this a bug or we can't use Collection.paginated_metrics for this case?
Getting all values with specified resolution from one metric is important feature for us.