Hello.
I have a task where i want to move data from one bucket to another.
In InfluxDB using the flux language I would like to set the bucket where I want to save my data using a variable.
But when I do that I can only set the start time a certain amount back in time otherwise I get an error. If I do not use the variable and I just write the bucket name directly as a string it works with all time ranges where there is data.
My flux query:
option task = {name: "AAA (cloned at 2024-08-14 13:22:00)", every: 1m, offset: 30s}
currentTime = int(v: uint(v: now()))
defaultEndDate = now()
MoveData = (
serialNum,
startDate,
measurement,
inBucket,
outBucket,
endDate=defaultEndDate,
) =>
{
initialStartDate = int(v: uint(v: time(v: startDate)))
endedDate = time(v: endDate)
is1m = true
is15m = int(v: currentTime % 900000000000) < 60000000000
isNightly = int(v: currentTime % 86400000000000) < 60000000000
initialLoad = currentTime < initialStartDate + int(v: 7d)
range15m =
from(bucket: inBucket)
|> range(start: time(v: startDate), stop: now())
|> filter(fn: (r) => r["_measurement"] == "Status")
|> filter(fn: (r) => r["Serial"] == serialNum)
|> map(
fn: (r) =>
({
_value: r._value,
_time: r._time,
_field: r._field,
Datatype: "Data",
_measurement: measurement,
_range: "7d",
}),
)
|> to(bucket: outBucket, org: "Blue North")
return range15m
}
MoveData(
serialNum: "ECO201099",
startDate: "2024-08-08T12:10:58.000Z",
measurement: "T00F040",
inBucket: "Indløbs Bucket - BS Data",
outBucket: "AAA",
)
The error I get:
could not execute task run: runtime error @28:20-38:18: map: incompatible builder for type string
Thanks!