Skip to content

Instantly share code, notes, and snippets.

require 'json'
file = File.read('./event.json')
event = JSON.parse(file)
keys = event['windows']['perfmon']['metrics']
keys.each{|key,value|
hash = {}
if ( key =~ /_/ )
key.split('_').reduce(hash) { |h,m| h[m] = {} }
puts hash.to_json
end
{
"@timestamp": "2022-04-20T22:05:01.466Z",
"@metadata": {
"beat": "metricbeat",
"type": "_doc",
"version": "7.17.0"
},
"metricset": {
"name": "perfmon",
"period": 10000
{
"@timestamp": "2022-04-20T22:05:01.466Z",
"@metadata": {
"beat": "metricbeat",
"type": "_doc",
"version": "7.17.0"
},
"metricset": {
"name": "perfmon",
"period": 10000
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
--- Volume group ---
VG Name storage
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Using stripesize of last segment 64.00 KiB
Using stripesize of last segment 64.00 KiB
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 232.9G 0 disk
├─md126 9:126 0 447.1G 0 raid0
│ ├─md126p1 259:0 0 512M 0 part /boot
│ ├─md126p2 259:1 0 414G 0 part /
│ └─md126p3 259:2 0 32.6G 0 part [SWAP]
└─md127 9:127 0 0B 0 md
sdb 8:16 0 223.6G 0 disk
├─md126 9:126 0 447.1G 0 raid0
│ ├─md126p1 259:0 0 512M 0 part /boot
--- Volume group ---
VG Name storage
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
--- Physical volume ---
PV Name /dev/sdc2
VG Name storage
PV Size <4.46 TiB / not usable <1.57 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1168647
Free PE 0
Allocated PE 1168647
PV UUID Bt6I6b-At5p-6wjC-yD39-ElDr-62o5-WCwR7L