Sha256: f63b459806c0f8b155369f4d2e9aeb4b1a5c74d634b6a57bb94f8baf85662a66
Contents?: true
Size: 750 Bytes
Versions: 1
Compression:
Stored size: 750 Bytes
Contents
module SnowmanIO module Checks # Gets last value from Hosted Graphite metric (https://www.hostedgraphite.com/) module HostedGraphite protected def get_hg_value(metric, options = {}) access_key = ENV["HG_KEY"] return nil unless access_key base_url = "https://www.hostedgraphite.com#{access_key}/graphite/render" from = options[:from] || "-10mins" url = base_url + "?format=json&target=#{URI.escape metric}&from=#{from}" handle = open(url) raw_data = JSON.parse(handle.gets) raw = raw_data.first datapoints = raw['datapoints'].delete_if { |v| v.first.nil? } if datapoints.last datapoints.last.first end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
snowman-io-0.0.4 | lib/snowman-io/checks/hosted_graphite.rb |