Documentation

Use the influxdb3 CLI to write data

InfluxDB 3 Enterprise is in Public Beta

InfluxDB 3 Enterprise is in public beta and available for testing and feedback, but is not meant for production use yet. Both the product and this documentation are works in progress. We welcome and encourage your input about your experience with the beta and invite you to join our public channels for updates and to share feedback.

Beta expectations and recommendations

Use the influxdb3 CLI to write line protocol data to InfluxDB 3 Enterprise.

Construct line protocol

With a basic understanding of line protocol, you can now construct line protocol and write data to InfluxDB 3 Enterprise. Consider a use case where you collect data from sensors in your home. Each sensor collects temperature, humidity, and carbon monoxide readings. To collect this data, use the following schema:

  • table: home
    • tags
      • room: Living Room or Kitchen
    • fields
      • temp: temperature in °C (float)
      • hum: percent humidity (float)
      • co: carbon monoxide in parts per million (integer)
    • timestamp: Unix timestamp in second precision

The following line protocol represent the schema described above:

home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1743148800
home,room=Kitchen temp=21.0,hum=35.9,co=0i 1743148800
home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1743152400
home,room=Kitchen temp=23.0,hum=36.2,co=0i 1743152400
home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1743156000
home,room=Kitchen temp=22.7,hum=36.1,co=0i 1743156000
home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1743159600
home,room=Kitchen temp=22.4,hum=36.0,co=0i 1743159600
home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1743163200
home,room=Kitchen temp=22.5,hum=36.0,co=0i 1743163200
home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1743166800
home,room=Kitchen temp=22.8,hum=36.5,co=1i 1743166800
  • Copy
  • Fill window

For this tutorial, you can either pass this line protocol directly to the influxdb3 write command as a string, via stdin, or you can save it to and read it from a file.

Write the line protocol to InfluxDB

Use the influxdb3 write command to write the home sensor sample data to InfluxDB 3 Enterprise. Provide the following:

  • The database name using the --database option

  • Your InfluxDB 3 Enterprise authorization token using the -t, --token option

  • Line protocol. Provide the line protocol in one of the following ways:

    • a string
    • a path to a file that contains the line protocol using the --file option
    • from stdin

InfluxDB 3 Enterprise auto-detects the timestamp precision by identifying which precision results in timestamps relatively close to “now.”

influxdb3 write \
  --database 
DATABASE_NAME
\
--token
AUTH_TOKEN
\
'home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1743148800 home,room=Kitchen temp=21.0,hum=35.9,co=0i 1743148800 home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1743152400 home,room=Kitchen temp=23.0,hum=36.2,co=0i 1743152400 home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1743156000 home,room=Kitchen temp=22.7,hum=36.1,co=0i 1743156000 home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1743159600 home,room=Kitchen temp=22.4,hum=36.0,co=0i 1743159600 home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1743163200 home,room=Kitchen temp=22.5,hum=36.0,co=0i 1743163200 home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1743166800 home,room=Kitchen temp=22.8,hum=36.5,co=1i 1743166800'
  • Copy
  • Fill window
  1. In your terminal, enter the following command to create the sample data file:

    echo 'home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000
    home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000
    home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600
    home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600
    home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200
    home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200
    home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800
    home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800
    home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400
    home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400
    home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000
    home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000' > ./home.lp
    
    • Copy
    • Fill window
  2. Enter the following CLI command to write the data from the sample file:

    influxdb3 write \
      --database 
    DATABASE_NAME
    \
    --token
    AUTH_TOKEN
    \
    ./home.lp
    • Copy
    • Fill window
  1. In your terminal, enter the following command to create the sample data file:

    echo 'home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000
    home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000
    home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600
    home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600
    home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200
    home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200
    home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800
    home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800
    home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400
    home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400
    home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000
    home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000' > ./home.lp
    
    • Copy
    • Fill window
  2. Enter the following CLI command to write the data from the sample file:

    cat ./home.lp | influxdb3 write \
      --database 
    DATABASE_NAME
    \
    --token
    AUTH_TOKEN
    • Copy
    • Fill window

Replace the following:

  • DATABASE_NAME: the name of the database to write to

  • AUTH_TOKEN: your InfluxDB 3 Enterprise authorization token

    While in beta, InfluxDB 3 Enterprise does not require an authorization token.


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out: