Hi all
I’m new to influxDB
I want to change the field type of measurement from string to float.
Please tell me how
Thanks
Hi all
I’m new to influxDB
I want to change the field type of measurement from string to float.
Please tell me how
Thanks
You have to achieve this in the gathering tool, not in InfluxDB itself
Can I change already saved string data to float data?
As far as I can determine this is not possible.
Once a measurement statistic is defined (by the first time it is added) it stays that type.
I had a runqueue as an integer but needed to change to a float = impossible.
So I changed the name coming from my data gathering tool to run_queue and added it as a float.
I guess you could extract data from InfluxDB change it - in your case removing the double quotes and then add it back under a new name.
Eventually you might prune out old data and remove in your case the strings.
Hope this helps, Nigel
Thank you for teaching me !
Hello @MOHTAKE,
You can use Flux to convert values however: Flux function types and categories | Flux 0.x Documentation
Can I use Flux in influxDB v1.8 ?
Please tell me how to run the program
Hello @MOHTAKE,
Yes!
Here you go Enable Flux | InfluxDB OSS 1.8 Documentation
Thanks @Anaisdg
I’m now trying using Flux to change the field type,
but I get the following error.
Please give me the advice
$ influx -type=flux -path-prefix /api/v2/query
Connected to http://localhost:8086/api/v2/query version 1.8.3
InfluxDB shell version: 1.8.3
from(bucket:“database”) |> range(start: -15000h) |> filter(fn: (r) => r._measurement == “measurement” ) |> toFloat()
Error: unknown server error: 500 Internal Server Error
Hello @MOHTAKE,
Do you know how much data that is?
Also have you considered using the UI? I find it useful for construction Flux queries and debugging.
There is an UI for Influx 1.8? I can’t fins info about that. Can you point me to the right direction?
I also need to change field types.
Hello @EDsteve,
Yes there’s a UI for 1.8.
It’s called Chronograf:
How are you writing data to influxDB? It would be better to change the field type before ingestion rather than after the fact.
You are right. It happened AFTER. Definitely setting it BEFORE next time. But it was not very important data. So i just made a new measurement at the end.
I use Graphana as data visualizer.
So with Chronograph i can change filed types? I didn’t know that.
Hello Anais, thanks for this. I have a problem with this.
I want to get the prices that have been stored as strings. Example: “1,000,000.00” or “1,250,000.55”
This prices are stored in a column named: “Valor_Fiscal”
My code is:
from(bucket: "realestatedata")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "real-estate-value")
|> filter(fn: (r) => r["Apartment_Building"] == "SW_JK")
|> filter(fn: (r) => r["_field"] == "Valor")
|> map(fn:(r) => ({r with "Valor": float(v: r["Valor"])}))
But when I see the raw data showing in the Data Explorer, the column _value is empty, therefore I think I cannot plot anything.
Do you see something wrong here?
There are around 128 lines showing up in the raw data
Hello @MGonzalez506,
If you want to filter for fields of a particular type use the isType() function:
import "types"
data
|> filter(fn: (r) => types.isType(v: r._value, type: "string"))
You can do the following instead
from(bucket: "realestatedata")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "real-estate-value")
|> filter(fn: (r) => r["Apartment_Building"] == "SW_JK")
|> filter(fn: (r) => r["_field"] == "Valor")
|> map(fn:(r) => ({r with "_value" : float(v: r["_value"])}))
Then you should be able to visualize them.
Otherwise you might be able to change which column you want to visualize in the customize settings at the top left of the data explorer.