rename() function

Warning! This page documents an earlier version of Flux, which is no longer actively developed. Flux v0.36 is the most recent stable version of Flux.

The rename() function renames specified columns in a table. If a column is renamed and is part of the group key, the column name in the group key will be updated.

There are two variants:

  • one which maps old column names to new column names
  • one which takes a mapping function.

Function type: Transformation
Output data type: Object

rename(columns: {host: "server", facility: "datacenter"})

// OR

rename(fn: (column) => "{column}_new")

Parameters

columns

A map of columns to rename and their corresponding new names. Cannot be used with fn.

Data type: Map

fn

A function which takes a single string parameter (the old column name) and returns a string representing the new column name. Cannot be used with columns.

Data type: Function

Examples

Rename a single column
from(bucket: "telegraf/autogen")
    |> range(start: -5m)
    |> rename(columns:{host: "server"})
Rename all columns using a function
from(bucket: "telegraf/autogen")
    |> range(start: -5m)
    |> rename(fn: (column) => "{column}_new")