How to rename some fields by using regex statement

this's my logstash output:

    "prometheus" => {   
        "metrics" => {
             "container_cpu_load_average_10s" => 0,
             "container_cpu_user_seconds_total" => 18.15,
             "container_cpu_system_seconds_total" => 12.64
        }
    },

now I want use one statement like this:

mutate {
          rename => {
              "[prometheus][metrics][.*]" => "[.*]"
          }
}

to implement like this:

mutate {
          rename => {
             "[prometheus][metrics][container_cpu_load_average_10s]" => "[container_cpu_load_average_10s]"
             "[prometheus][metrics][container_cpu_user_seconds_total]" => "[container_cpu_user_seconds_total]"
             "[prometheus][metrics][container_cpu_system_seconds_total]" => "[container_cpu_system_seconds_total]"
          }
}

Can you help me?Pls!

You could rename a variable set of fields using a filter like this.

It works! Gratefully!

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