Search code examples
influxdb-2fluxlang

How to join a string value from a tag with a string value from a field?


consider having the following line protocol data:

my_measurement,foo="Some" bar="Thing",baz=123

where foo is a tag and bar and baz are fields, I need to get, say, a string "Some|Thing" out of InfluxDB OSS v2 using the Flux language. What's the trick? How to do it? There is the strings.joinStr() and the keyValues() functions I feel could be perhaps used to get the desired values but I failed to do so.


Solution

  • You can do this with map(), for example:

    |> map(fn: (r) => ({r with newColName: r.foo+r._bar}))
    

    Or, if you have to convert the type of _field,

    |> map(fn: (r) => ({r with newColName: r.foo+string(v: r._baz)}))