Hello, I have a collection of about two years of sensor data that I get via MQTT. I want to do some small changes to a few MQTT topic names to make them shorter.
I would like to change my key values so they would match the new topic names. How should I do this?
Currently I have something working in Flux but it is not efficient at all. I’m still very new in the flux language.
extractedA = from(bucket: "oldBucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "LocationA")
|> filter(fn: (r) => r["source"] == "Water log")
|> filter(fn: (r) => r["_field"] == "total m3 extracted A")
|> set(key: "source", value: "WaterLog")
|> set(key: "_field", value: "TotalExtractedA")
extractedB = from(bucket: "oldBucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "LocationA")
|> filter(fn: (r) => r["source"] == "Water log")
|> filter(fn: (r) => r["_field"] == "total m3 extracted B")
|> set(key: "source", value: "WaterLog")
|> set(key: "_field", value: "TotalExtractedB")
extractedA |> to(bucket: "newBucket")
extractedB |> to(bucket: "newBucket")
What would be the most efficient way to do this? Can this be done in one query or should i avoid Flux at all? I want to change the “source” and _field key values to match my new MQTT topics.
Thanks!