Bringing in a tag value from one bucket into another bucket

Hi there! I’m writing a task to run on a hourly basis. I need to bring in an existing tag name and value from the same bucket as an output for my new bucket. Is there a way to do this? This is the query for the task. Right now, I’m using this as a placeholder but over time it won’t work when there are many values for site_name: |> set(key: "site_name", value: "*") Thanks for the guidance!

import "influxdata/influxdb/schema"
import "date"

option task = {name: "batteryavailability", cron: "5 * * * *"}

from(bucket: "rt-data")
    |> range(
        start: date.sub(from: date.truncate(t: now(), unit: 1h), d: 1h),
        stop: date.truncate(t: now(), unit: 1h),
    |> filter(fn: (r) => r["_measurement"] == "site")
    |> filter(fn: (r) => r["point_name"] == "racks_online" or r["point_name"] == "racks_total")
    |> group(columns: ["_measurement"], mode: "by")
    |> pivot(rowKey: ["_time"], columnKey: ["point_name"], valueColumn: "_value")
    |> map(fn: (r) => ({r with batteryavailability: r.racks_online / r.racks_total}))
    |> rename(columns: {batteryavailability: "_value"})
    |> aggregateWindow(every: 1h, fn: mean)
    |> set(key: "point_name", value: "batteryavailability")
    |> set(key: "_measurement", value: "site")
    |> set(key: "_field", value: "value")
    |> set(key: "site_name", value: "*")
    |> to(bucket: "dashboard-metrics", org: "fractal")