Mutate Value to Keyname


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?



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)

If you really have a space in " Segment" you might want to add code to fix that.


Thank you very much, this worked for me.

the space in " Segment" was my writing error

(system) closed #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.