Map math division and integers

I am trying to create a % value using a join and map. The joined tables _values are of type int which is how they are stored in InfluxDB. The calculation is always returning an int.

I have tried each of the type conversions which all return internal server error in Chronograf. Looking at the docs it looks like there is a cast function ‘float(value)’ but using this fails to compile the query.

Using InfluxDB 1.7.2 with the built-in Flux.
Is there an updated nightly Flux docker image available? I see there is one on but it is outdated.

Hello @dan-hughes,

float won’t work on a whole table. You have to run it via map() on a column. Something like from(bucket: "telegraf/autogen") |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_user") |> map(fn: (r) => ({_value: float(v: r._value)})

toFloat is what you actually want. It works on streams of tables. However, note that it will drop all other columns not part of the group key.

Hi @Anaisdg,

Thank you for your response, which version of Influx did you try this on? I just tried on 1.7.2 using Chronograf 1.7.4 and get an internal server error.

Thank you for creating an issue. It’s not working for me in flux as well.