Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Last active August 29, 2015 14:02
Show Gist options
  • Save dallasmarlow/1d21bcbb44020ae4a856 to your computer and use it in GitHub Desktop.
Save dallasmarlow/1d21bcbb44020ae4a856 to your computer and use it in GitHub Desktop.
filtering datapoints over a specific quantile using tsd_client
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