Documentation

Work with strings

A string type represents a sequence of characters. Strings are immutable and cannot be modified once created.

Type name: string

String syntax

A string literal is represented by a sequence of characters enclosed in double quotes ("). Any character may appear inside a string literal except an unescaped double quote. String literals support several escape sequences and hex encoding using \x as a prefix.

"abc"
"string with double \" quote"
"string with backslash \\"
"日本語"
"\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"

Convert data types to strings

Use the string() function to convert other basic types to strings:

  • boolean
  • bytes
  • duration
  • float
  • int
  • uint
  • time
string(v: 42)
// Returns "42"

Convert regular expressions to strings

To convert a regular expression to a string:

  1. Import the regexp package.
  2. Use regexp.getString() and provide the regular expression to convert to a string.
import "regexp"

regexp.getString(r: /[a-zA-Z]/)
// Returns [a-zA-Z] (string)

Convert data types to hexadecimal strings

To convert basic types to hexadecimal strings:

  1. Import the contrib/bonitoo-io/hex package.
  2. Use hex.string() to convert other a value to a hexadecimal string.
import "contrib/bonitoo-io/hex"

hex.string(v: 123456)
// Returns 1e240

Convert columns to strings

Flux lets you iterate over rows in a stream of tables and convert columns to strings.

To convert the _value column to strings, use the toString() function.

toString() only operates on the _value column.

data
    |> toString()
Given the following input data:
_time_value (int)
2021-01-01T00:00:00Z1
2021-01-01T02:00:00Z2
2021-01-01T03:00:00Z3
2021-01-01T04:00:00Z4
The example above returns:
_time_value (string)
2021-01-01T00:00:00Z1
2021-01-01T02:00:00Z2
2021-01-01T03:00:00Z3
2021-01-01T04:00:00Z4

To convert any column to strings:

  1. Use map() to iterate over and rewrite rows.
  2. Use string() to convert columns values to strings.
data
    |> map(fn: (r) => ({ r with level: string(v: r.level) }))
Given the following input data:
_timelevel (int)
2021-01-01T00:00:00Z1
2021-01-01T02:00:00Z2
2021-01-01T03:00:00Z3
2021-01-01T04:00:00Z4
The example above returns:
_timelevel (string)
2021-01-01T00:00:00Z1
2021-01-01T02:00:00Z2
2021-01-01T03:00:00Z3
2021-01-01T04:00:00Z4

Operate on strings

Use functions in the Flux strings package to perform operations including:

Interpolate strings

To interpolate strings in another Flux string, enclose embedded expressions in a dollar sign and curly braces ${}. Flux replaces the placeholder with the result of the embedded expression and returns a string literal.

name = "John"
"My name is ${name}."
// My name is John.

d = 1m
"the answer is ${d}"
// the answer is 1m

t0 = 2016-06-13T17:43:50Z
"the answer is ${t0}"
// the answer is 2016-06-13T17:43:50.000000000Z

p = {name: "John", age: 42}
"My name is ${p.name} and I'm ${p.age} years old."
// My name is John and I'm 42 years old.

String interpolation expressions must satisfy the Stringable constraint.

Concatenate strings

To concatenate Flux strings, use the + operator between string values or expressions that resolve to strings. Flux resolves expressions and returns a single concatenated string.

Concatenated expressions must resolve to strings.

name = "John"
"My name is " + name + "."
// My name is John.

d = 1m
"the answer is " + string(v: d)
// the answer is 1m

t0 = 2016-06-13T17:43:50Z
"the answer is " + string(v: t0)
// the answer is 2016-06-13T17:43:50.000000000Z

p = {name: "John", age: 42}
"My name is " + p.name + " and I'm " + string(v: p.age) + " years old."
// My name is John and I'm 42 years old.

Was this page helpful?

Thank you for your feedback!


InfluxDB OSS 2.9.0: API tokens are hashed by default

Stronger token security in InfluxDB OSS 2.9.0 — tokens are hashed on disk by default. Existing tokens are hashed on first startup and can’t be recovered afterward. Capture any plaintext tokens you still need before you upgrade.

View InfluxDB OSS 2.9.0 release notes

Hashed tokens authenticate exactly like unhashed tokens — clients and integrations keep working.

Also new in 2.9.0:

  • Configurable backup compression
  • Restore support for backups containing hashed tokens
  • Tighter Edge Data Replication queue validation
  • Flux upgrade
  • Compaction reliability improvements

Key enhancements in Explorer 1.8

Explorer 1.8 is now available with streaming data subscriptions (beta), line protocol preview, and query history & saved queries.

View Explorer 1.8 release notes

Explorer 1.8 includes new features and improvements that make it easier to ingest, explore, and manage data.

Highlights:

  • Streaming data subscriptions (beta): Stream data into Explorer from MQTT, Kafka, and AMQP sources.
  • Line protocol preview: Preview line protocol, schema, and parse errors before data is written.
  • Custom sample data: Generate custom sample datasets with line protocol and schema preview.
  • Query history and saved queries: Browse query history and save/re-run named queries.
  • Retention period management: Set, update, or clear retention periods on databases and tables.

For more details, see Explorer 1.8 release notes

InfluxDB 3.9: Performance upgrade preview

InfluxDB 3 Enterprise 3.9 includes a beta of major performance upgrades with faster single-series queries, wide-and-sparse table support, and more.

InfluxDB 3 Enterprise 3.9 includes a beta of major performance and feature updates.

Key improvements:

  • Faster single-series queries
  • Consistent resource usage
  • Wide-and-sparse table support
  • Automatic distinct value caches for reduced latency with metadata queries

Preview features are subject to breaking changes.

For more information, see:

Telegraf Enterprise now in public beta

Get early access to the Telegraf Controller and provide feedback to help shape the future of Telegraf Enterprise.

See the Blog Post

The upcoming Telegraf Enterprise offering is for organizations running Telegraf at scale and is comprised of two key components:

  • Telegraf Controller: A control plane (UI + API) that centralizes Telegraf configuration management and agent health visibility.
  • Telegraf Enterprise Support: Official support for Telegraf Controller and Telegraf plugins.

Join the Telegraf Enterprise beta to get early access to the Telegraf Controller and provide feedback to help shape the future of Telegraf Enterprise.

For more information:

Telegraf Controller v0.0.7-beta now available

Telegraf Controller v0.0.7-beta is now available with new features, improvements, bug fixes, and an important breaking change.

View the release notes
Download Telegraf Controller v0.0.7-beta

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On May 27, 2026, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2