How to make alias in Flux query

I’ve a query in influxql where I can see an alias field as follows:


SELECT top("value","name",1) FROM (SELECT non_negative_derivative(last("weighted_io_time"), 1ms) AS "value" FROM "diskio" WHERE ("host" =~ /^$data_nodes_prod$/ AND "name" !~ /[0-9]/) AND $timeFilter GROUP BY time($__interval), "host", "name" fill(null)) GROUP BY "host"

Alias by: $tag_host $tag_name

Output caption: vm-influxdb-data-01-dev: sdc

I’ve converted this query to flux but unable to set the alias and my caption on Grafana looks very odd and long.

Flux query:
from(bucket: v.bucket)
|> range(start: v.timeRangeStart)
|> filter(fn: (r) => r._measurement == “diskio”)
|> filter(fn: (r) => r._field == “weighted_io_time”)
|> filter(fn: (r) => r[“name”] == “sdc”)
|> filter(fn: (r) => contains(value: r[“host”], set: ${data_nodes:json}))
|> derivative(unit: 1ms, nonNegative: true)
|> top(n: 1)

captions looks like: weighted_io_time {_environment=“pdev”, resourcegroup=“rg-influx-enterpise_prod_westeu”, cluster_id=“a961cf99-8de7-9cf5487c2656”, environment=“dev”, host=“vm-influxdb-data-01-dev”, name=“sdc”, node=“data”}

I’m not sure how exactly I can set the alias based on “$tag_host $tag_name”.