Created
December 27, 2011 23:48
-
-
Save trinary/1525490 to your computer and use it in GitHub Desktop.
This file contains 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
#!ruby | |
# Save this as obs2csv.rb | |
# | |
# This requires yajl. Install yajl by doing the following: | |
# gem install yajl-ruby | |
# | |
# To run, pipe in non-color JSON from ndcurl to an observations resource, like so: | |
# ndcurl http://core.ss-internal2.den.sysshep.com/metrics/13530/observations\?start\=2011-12-01T00:00:00Z\&end\=2011-12-25T00:00:00Z | ruby ./obs2csv.rb > foo.csv | |
require 'rubygems' | |
require 'yajl' | |
p = Yajl::Parser.new | |
j = p.parse(STDIN.read) | |
j["items"].each do |i| | |
puts "#{i['timestamp']},#{i['value']}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment