For more details on configuring the QuestDB server with ingestion settings, refer to the InfluxDB API reference.
InfluxDB line protocol messages have the following syntax:
The data of each row is serialized in a “pseudo-CSV” format where each line is composed of the following:
- several comma-separated items of tags in the format followed by a space
- several comma-separated items of fields in the format
<label>=<value>
followed by a space - an optional timestamp for the record
- a newline character
\n
A single line of text in line protocol format represents one table row QuestDB. Consider the following InfluxDB line protocol message:
sensors,location=london-1 temperature=22 1465839830100400200
This would create a new row in the sensors
table with the following contents:
InfluxDB have the following description of the elements of line protocol:
measurementName,tagKey=tagValue fieldKey="fieldValue" 1465839830100400200
--------------- --------------- --------------------- -------------------
| | | |
Measurement Tags Fields Timestamp
In the context of QuestDB, it should be noted that the measurementName
element equates to a table name.
Naming restrictions
Tag keys and field keys in InfluxDB line protocol messages equate to column names. In QuestDB, column names cannot contain the following characters, and as such, tag and field keys must not contain any of the following characters:
_sensor_data,_sensor=london_1 _value=12.4,string="sensor data, rev 1"
Note that spaces and commas do not require an escaping backslash in the field value for string
.
Field values may be parsed by QuestDB as one of the following types:
long
boolean
All subsequent field values must match the type of the first row written to a given column.
:::info
For details on the available data types in QuestDB, see the data types reference.
:::
If field values are passed string types, the field values must be double-quoted. Special characters are supported without escaping:
sensors,location=london temperature=22,software_version="A.B C-123"
sensors,location=london temperature=22,software_version="SV .#_123"
For string types in QuestDB, the storage is allocated as 32+n*16
bits where n
is the string length with a maximum value of 0x7fffffff
.
The sensors
table would have the following row added:
QuestDB handles long
types as a signed integer from 0x8000000000000000L
to 0x7fffffffffffffffL
.
Boolean values can be passed in InfluxDB line protocol messages with any of the following:
The following example adds a boolean
type column called warning
:
sensors,location=london temperature=22,warning=false
Table schema
It is not necessary to create a table schema for messages passed via InfluxDB line protocol. A table will be dynamically created if one does not exist. If new columns are added as field or tag sets, the table is automatically updated to reflect the new structure and the new column will be back-propagated with null values.
When new tables are created by inserting records via InfluxDB line protocol, a default partitioning strategy by DAY
is applied. This default can be overridden by means of passing server configuration for line.tcp.default.partition.by
, i.e.
line.tcp.default.partition.by=MONTH
For information describing how to pass server settings to QuestDB, see the page.
QuestDB can ingest line protocol packets both over TCP and UDP with the following defaults:
- InfluxDB TCP listener on port by default
- InfluxDB UDP listener on port
9009
by default
Examples
The following basic Python example demonstrates how to stream InfluxDB line protocol messages to QuestDB over TCP. For more examples using different languages, see the insert data documentation.