rebort
February 13, 2019, 10:33am
1
Hi, i have a Problem and i need a hint.
I get this keys:
{
"deviceCustomString1": "segmentA",
"deviceCustomString1Label": " Segment",
"deviceCustomString2": "c833-cb3804056",
"deviceCustomString2Label": "Policy UUID"
}
I need to mutate the Value from deviceCustomStringXLabel as a Key for the Value in deviceCustomStringX
until now i see in debug that the Number goes up to 8. So i search for an generic way to do this mutation. Any Hints?
Thanks
Badger
February 13, 2019, 11:29am
2
Try something like
ruby {
code => '
event.to_hash.each { |k, v|
if k.match(/Label$/)
newk = k.gsub(/(.*)Label$/, "\\1")
newv = event.get(newk)
if newv
event.set(v, newv)
event.remove(k)
event.remove(newk)
end
end
}
'
}
If you really have a space in " Segment" you might want to add code to fix that.
rebort
February 13, 2019, 1:04pm
3
Thank you very much, this worked for me.
the space in " Segment" was my writing error
system
(system)
Closed
March 13, 2019, 1:09pm
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.