Skip to content

Instantly share code, notes, and snippets.

@trinary
Created December 27, 2011 23:48
Show Gist options
  • Save trinary/1525490 to your computer and use it in GitHub Desktop.
Save trinary/1525490 to your computer and use it in GitHub Desktop.
#!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