Hello,
Im trying to get the cpu core values in a single array on my logstash config . I'm not familiar with ruby code, however based on my very limited understanding i was able to do this . It has the cpu core values , but not in an array .
What am i missing here ?
dissect
{
mapping => {"message" => "%{time}|%{rest}all %{Overall_CPU_usage}%, %{CPU} TX %{TX_Value_Mbps} "}
}
}
kv
{
source => "CPU"
value_split => " "
remove_char_value => "%"
}
ruby
{
code => '
cpu_core = []
event.to_hash.each { |k, v|
if k =~/^\d+$/
cpu_core[k]=[v];
end
}
event.set("CPU-Usage",cpu_core)
'
}
}
OUTPUT
{
"c7" => "37,",
"TX_Value_Mbps" => "198",
"CPU-Usage" => [], <<<<<<<< #EMPTY ARRAY
"@timestamp" => 2021-06-06T20:33:55.629Z,
"c3" => "36,",
"c1" => "44,",
"c5" => "42,",
"c2" => "31,",
"c4" => "38,",
"Overall_CPU_usage" => "39",
"c0" => "41,",
"c6" => "44,",
}