How i can rename dynamical fields

Hello, I would like some help with my little problem. I would like to be able to automatically rename fields that I get with my snmp plugin in input.

I obtain this result:

"host" => [ 
[1] {
      "iso...hrProcessorLoad" => 10
[2] {
      "iso...hrProcessorLoad" => 9

At the moment I use this:

mutate {
                   rename => { "[host][1][iso...hrProcessorLoad]" => ProcessorLoad1

But I would like to automate this function.

I thank you in advance for your answers

You must use ruby. Check here.

If you are not adept at writing ruby you could start with something like

    ruby {
        code => '
            h = event.get("host")
            if h and h.respond_to? "each_index"
                h.each_index { |i| event.set("hrProcessorLoad#{i}", h[i]["iso...hrProcessorLoad"]) }

Thank's it works good

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