问题
Is it possible to convert a tag (which is string) to make field (like double) which would contain a transformed version of the tag value? Like an QL update expression?
回答1:
One could use influx_inspect export
to dump the database in the line protocol format. Then relevant columns could be grepped and modified with your favorite tool, like python or sed/bash. And the modified time series could be re-inserted directly into the database (one could use split -l 7000
to split field time series into chunks and the use curl -POST .../write?db=... --data-binary @chunk
and iterate over those chunks expecting HTTP 204 for correctly inserted values).
回答2:
This is only possibly using Kapacitor
stream()
|from()
.measurement('mymeasurement')
|log() // outputs the current state of the pipelie
|eval(lambda: float("mytag"))
.as('myfield')
.keep()
|log()
来源:https://stackoverflow.com/questions/42392682/convert-tag-to-field-in-influxdb