Write data with line protocol
Use line protocol to write data to InfluxDB Cloud. Line protocol is a text-based format that provides the measurement, tag set, field set, and timestamp of a data point. Learn more about line protocol.
Write data using line protocol with the following methods:
Write line protocol using the influx write command
Use the influx write
command to write data using line protocol
to InfluxDB.
Set the path to the line protocol file using the -f
flag.
Verify that your line protocol follows the correct line protocol format conventions.
Example write command
influx write -b example-bucket -f path/to/example.txt
line protocol format
mem,host=host1 used_percent=64.23 1577836800000000000
mem,host=host2 used_percent=72.01 1577836800000000000
mem,host=host1 used_percent=62.61 1577836810000000000
mem,host=host2 used_percent=72.98 1577836810000000000
mem,host=host1 used_percent=63.40 1577836820000000000
mem,host=host2 used_percent=73.77 1577836820000000000
Line protocol data looks like this:
mem,host=host1 used_percent=23.43234543 1556892576842902000
cpu,host=host1 usage_user=3.8234,usage_system=4.23874 1556892726597397000
mem,host=host1 used_percent=21.83599203 1556892777007291000
Write line protocol
- via stdin
- from a file
- from multiple files
- from a URL
- from multiple URLs
- from multiple sources
- from a compressed file
Write line protocol via stdin
influx write --bucket example-bucket "
m,host=host1 field1=1.2
m,host=host2 field1=2.4
m,host=host1 field2=5i
m,host=host2 field2=3i
"
Write line protocol from a file
influx write \
--bucket example-bucket \
--file path/to/line-protocol.txt
Write line protocol from multiple files
influx write \
--bucket example-bucket \
--file path/to/line-protocol-1.txt \
--file path/to/line-protocol-2.txt
Write line protocol from a URL
influx write \
--bucket example-bucket \
--url https://example.com/line-protocol.txt
Write line protocol from multiple URLs
influx write \
--bucket example-bucket \
--url https://example.com/line-protocol-1.txt \
--url https://example.com/line-protocol-2.txt
Write line protocol from multiple sources
influx write \
--bucket example-bucket \
--file path/to/line-protocol-1.txt \
--url https://example.com/line-protocol-2.txt
Write line protocol from a compressed file
# The influx CLI assumes files with the .gz extension use gzip compression
influx write \
--bucket example-bucket \
--file path/to/line-protocol.txt.gz
# Specify gzip compression for gzipped files without the .gz extension
influx write \
--bucket example-bucket \
--file path/to/line-protocol.txt.comp \
--compression gzip
InfluxDB Cloud limits data in an uncompressed write request payload to 250 MB. After 250 MB is uncompressed and written, the remaining lines are not written, and the caller receives a 413 response. We recommend the caller retry the request with a smaller uncompressed payload.
Timestamp precision
When writing data to InfluxDB, we recommend including a timestamp with each point. If a data point does not include a timestamp when it is received by the database, InfluxDB uses the current system time (UTC) of its host machine.
The default precision for timestamps is in nanoseconds.
If the precision of the timestamps is anything other than nanoseconds (ns
),
you must specify the precision in your write request.
InfluxDB accepts the following precisions:
ns
- Nanosecondsus
- Microsecondsms
- Millisecondss
- Seconds
For more details about line protocol, see the Line protocol reference and Best practices for writing data.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.