We need to convert field to tag in influxDB v2.0 but not able to find any proper solution. Can someone help me out to achieve the same ?
Solution we found was to create new measurement by altering fields and tags of existing measurement but not able achieve it using Flux language.
Using below flux query we can copy the data from one measurement to another but not able to change the field to tag while adding data in new measurement.
from(bucket: "bucket_name")
|> range(start: -10y)
|> filter(fn: (r) => r._measurement == "cu_om")
|> aggregateWindow(every: 5s, fn: last, createEmpty: false)
|> yield(name: "last")
|> set(key: "_measurement", value: "cu_om_new1")
|> to(org: "org_name", bucket: "bucket_name")
Any help appreciated.