Last active
August 29, 2015 14:02
-
-
Save dallasmarlow/1d21bcbb44020ae4a856 to your computer and use it in GitHub Desktop.
filtering datapoints over a specific quantile using tsd_client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tsd_client' | |
tsd = TSD::Client.new host: 'fibr' | |
quantile = 0.95 | |
query = metric: 'cache_error_errs', | |
start: Time.parse('2014/06/11-12:00:00'), | |
rate: true, | |
tags: {host: '*'} | |
results = tsd.query(query).sort_by {|entry| entry[:value]} | |
boundary = results.fetch((quantile * results.size).ceil - 1) | |
results.each do |entry| | |
p entry if entry[:value] >= boundary | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment