Rename column name in output?

With Flux language syntex, how tu rename column name in result tables? Like “as name” in sql “select n1 as name from …”.

eg.

from(bucket: “${bucket}”)
|> range(start: v.timeRangeStart)
|> filter(fn: (r) => r.host == “${host}”)
|> filter(fn: (r) => r._measurement == “mem”)
|> filter(fn: (r) => r._field == “used_percent” or r._field == “cached” or r._field == “free” or r._field == “buffered”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)

> yield(name: “mean”)

In above query, I want to change “used_percent” “cached” to something else in order to modify the column names in the data output and affect the names of the legend.

I’m not knowledgeable in Flux, so I’ll tell you how you can do that on Grafana itself.

You can use the Organize fields transform to reorder and rename columns/fields

2 Likes