Skip to content

Instantly share code, notes, and snippets.

@gschanuel
Created April 25, 2022 17:01
Show Gist options
  • Save gschanuel/5dd4c69cb3c8cf87b585557e24a9757c to your computer and use it in GitHub Desktop.
Save gschanuel/5dd4c69cb3c8cf87b585557e24a9757c to your computer and use it in GitHub Desktop.
require 'json'
file = File.read('./event.json')
event = JSON.parse(file)
keys = event['windows']['perfmon']['metrics'].to_hash.keys
keys.each{|key|
if ( key =~ /_/ )
newkey = key.split("_").map { "[#{_1}]" }.join
event['windows']['perfmon']['metrics'].store(newkey, event['windows']['perfmon']['metrics'].delete(key))
end
}
puts event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment