2019-05-02 22:58:59 +00:00
|
|
|
|
---
|
|
|
|
|
title: Line protocol reference
|
|
|
|
|
description: >
|
2019-05-07 02:42:37 +00:00
|
|
|
|
InfluxDB uses line protocol to write data points.
|
2019-05-06 14:46:18 +00:00
|
|
|
|
It is a text-based format that provides the measurement, tag set, field set, and timestamp of a data point.
|
2019-05-02 22:58:59 +00:00
|
|
|
|
menu:
|
|
|
|
|
v2_0_ref:
|
|
|
|
|
name: Line protocol
|
|
|
|
|
weight: 6
|
|
|
|
|
v2.0/tags: [write, line protocol]
|
|
|
|
|
---
|
|
|
|
|
|
2019-05-07 02:42:37 +00:00
|
|
|
|
InfluxDB uses line protocol to write data points.
|
2019-05-06 14:46:18 +00:00
|
|
|
|
It is a text-based format that provides the measurement, tag set, field set, and timestamp of a data point.
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
2019-05-07 02:42:37 +00:00
|
|
|
|
- [Elements of line protocol](#elements-of-line-protocol)
|
2019-05-02 22:58:59 +00:00
|
|
|
|
- [Data types and format](#data-types-and-format)
|
2019-05-06 14:46:18 +00:00
|
|
|
|
- [Quotes](#quotes)
|
2019-05-02 22:58:59 +00:00
|
|
|
|
- [Special characters](#special-characters)
|
|
|
|
|
- [Comments](#comments)
|
|
|
|
|
- [Naming restrictions](#naming-restrictions)
|
|
|
|
|
- [Duplicate points](#duplicate-points)
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// Syntax
|
|
|
|
|
<measurement>[,<tag_key>=<tag_value>[,<tag_key>=<tag_value>]] <field_key>=<field_value>[,<field_key>=<field_value>] [<timestamp>]
|
|
|
|
|
|
|
|
|
|
// Example
|
|
|
|
|
myMeasurement,tag1=value1,tag2=value2 fieldKey="fieldValue" 1556813561098000000
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Lines separated by the newline character `\n` represent a single point
|
2019-05-07 02:42:37 +00:00
|
|
|
|
in InfluxDB. Line protocol is whitespace sensitive.
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
{{% note %}}
|
|
|
|
|
Line protocol does not support the newline character `\n` in tag or field values.
|
|
|
|
|
{{% /note %}}
|
|
|
|
|
|
2019-05-07 02:42:37 +00:00
|
|
|
|
## Elements of line protocol
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
measurementName,tagKey=tagValue fieldKey="fieldValue" 1465839830100400200
|
|
|
|
|
--------------- --------------- --------------------- -------------------
|
|
|
|
|
| | | |
|
|
|
|
|
Measurement Tag set Field set Timestamp
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Measurement
|
|
|
|
|
<span class="required">Required</span> –
|
|
|
|
|
The measurement name.
|
|
|
|
|
InfluxDB accepts one measurement per point.
|
2019-05-06 14:46:18 +00:00
|
|
|
|
_Measurement names are case-sensitive and subject to [naming restrictions](#naming-restrictions)._
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
_**Data type:** [String](#string)_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Tag set
|
|
|
|
|
_**Optional**_ –
|
|
|
|
|
All tag key-value pairs for the point.
|
|
|
|
|
Key-value relationships are denoted with the `=` operand.
|
|
|
|
|
Multiple tag key-value pairs are comma-delimited.
|
2019-05-06 14:46:18 +00:00
|
|
|
|
_Tag keys and tag values are case-sensitive.
|
2019-05-02 22:58:59 +00:00
|
|
|
|
Tag keys are subject to [naming restrictions](#naming-restrictions)._
|
|
|
|
|
|
|
|
|
|
_**Key data type:** [String](#string)_
|
|
|
|
|
_**Value data type:** [String](#string)_
|
|
|
|
|
|
|
|
|
|
_See [naming restrictions](#naming-restrictions)_
|
|
|
|
|
|
|
|
|
|
### Field set
|
|
|
|
|
<span class="required">Required</span> –
|
|
|
|
|
All field key-value pairs for the point.
|
|
|
|
|
Points must have at least one field.
|
2019-05-06 14:46:18 +00:00
|
|
|
|
_Field keys and string values are case-sensitive.
|
2019-05-02 22:58:59 +00:00
|
|
|
|
Field keys are subject to [naming restrictions](#naming-restrictions)._
|
|
|
|
|
|
|
|
|
|
_**Key data type:** [String](#string)_
|
|
|
|
|
_**Value data type:** [Float](#float) | [Integer](#integer) | [String](#string) | [Boolean](#boolean)_
|
|
|
|
|
|
|
|
|
|
_See [naming restrictions](#naming-restrictions)_
|
|
|
|
|
|
|
|
|
|
{{% note %}}
|
2019-05-06 14:46:18 +00:00
|
|
|
|
_Always double quote string field values. More on quotes [below](#quotes)._
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
measurementName fieldKey="field string value" 1556813561098000000
|
|
|
|
|
```
|
|
|
|
|
{{% /note %}}
|
|
|
|
|
|
|
|
|
|
### Timestamp
|
|
|
|
|
_**Optional**_ –
|
|
|
|
|
The Unix nanosecond timestamp for the data point.
|
|
|
|
|
InfluxDB accepts one timestamp per point.
|
|
|
|
|
If no timestamp is provided, InfluxDB uses the system time (UTC) of its host machine.
|
|
|
|
|
|
2019-09-18 22:25:29 +00:00
|
|
|
|
_**Data type:** [Unix timestamp](#unix-timestamp)_
|
|
|
|
|
|
|
|
|
|
{{% note %}}
|
2019-09-18 22:27:02 +00:00
|
|
|
|
Though timestamps are optional, include them to ensure times associated with points
|
2019-09-18 22:25:29 +00:00
|
|
|
|
are the actual times metrics were observed rather than when InfluxDB received them.
|
|
|
|
|
{{% /note %}}
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
{{% note %}}
|
2019-05-06 14:46:18 +00:00
|
|
|
|
_Use the default nanosecond precision timestamp or specify an alternative precision
|
2019-05-07 02:42:37 +00:00
|
|
|
|
when [writing the data](/v2.0/write-data/#precision)._
|
2019-05-02 22:58:59 +00:00
|
|
|
|
{{% /note %}}
|
|
|
|
|
|
|
|
|
|
### Whitespace
|
2019-05-06 14:46:18 +00:00
|
|
|
|
Whitespace in line protocol determines how InfluxDB interprets the data point.
|
|
|
|
|
The **first unescaped space** delimits the measurement and the tag set from the field set.
|
|
|
|
|
The **second unescaped space** delimits the field set from the timestamp.
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
measurementName,tagKey=tagValue fieldKey="fieldValue" 1465839830100400200
|
|
|
|
|
┬ ┬
|
|
|
|
|
1st space 2nd space
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Data types and format
|
|
|
|
|
|
|
|
|
|
### Float
|
|
|
|
|
IEEE-754 64-bit floating-point numbers.
|
2019-05-06 14:46:18 +00:00
|
|
|
|
Default numerical type.
|
|
|
|
|
_InfluxDB supports scientific notation in float field values._
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
##### Float field value examples
|
|
|
|
|
```js
|
|
|
|
|
myMeasurement fieldKey=1.0
|
|
|
|
|
myMeasurement fieldKey=1
|
|
|
|
|
myMeasurement fieldKey=-1.234456e+78
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Integer
|
|
|
|
|
Signed 64-bit integers.
|
2019-05-06 14:46:18 +00:00
|
|
|
|
Trailing `i` on the number specifies an integer.
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
| Minimum integer | Maximum integer |
|
|
|
|
|
| --------------- | --------------- |
|
|
|
|
|
| `-9223372036854775808i` | `9223372036854775807i` |
|
|
|
|
|
|
|
|
|
|
##### Integer field value examples
|
|
|
|
|
```js
|
|
|
|
|
myMeasurement fieldKey=1i
|
|
|
|
|
myMeasurement fieldKey=12485903i
|
|
|
|
|
myMeasurement fieldKey=-12485903i
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### String
|
|
|
|
|
Plain text string.
|
|
|
|
|
Length limit 64KB.
|
|
|
|
|
|
|
|
|
|
##### String example
|
|
|
|
|
```sh
|
|
|
|
|
# String measurement name, field key, and field value
|
|
|
|
|
myMeasurement fieldKey="this is a string"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Boolean
|
|
|
|
|
Stores `true` or `false` values.
|
|
|
|
|
|
|
|
|
|
| Boolean value | Accepted syntax |
|
|
|
|
|
|:-------------:|:--------------- |
|
|
|
|
|
| True | `t`, `T`, `true`, `True`, `TRUE` |
|
|
|
|
|
| False | `f`, `F`, `false`, `False`, `FALSE` |
|
|
|
|
|
|
|
|
|
|
##### Boolean field value examples
|
|
|
|
|
```js
|
|
|
|
|
myMeasurement fieldKey=true
|
|
|
|
|
myMeasurement fieldKey=false
|
|
|
|
|
myMeasurement fieldKey=t
|
|
|
|
|
myMeasurement fieldKey=f
|
|
|
|
|
myMeasurement fieldKey=TRUE
|
|
|
|
|
myMeasurement fieldKey=FALSE
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
{{% note %}}
|
|
|
|
|
Do not quote boolean field values.
|
|
|
|
|
Quoted field values are interpreted as strings.
|
|
|
|
|
{{% /note %}}
|
|
|
|
|
|
|
|
|
|
### Unix timestamp
|
|
|
|
|
Unix nanosecond timestamp.
|
|
|
|
|
|
|
|
|
|
| Minimum timestamp | Maximum timestamp |
|
|
|
|
|
| ----------------- | ----------------- |
|
|
|
|
|
| `-9223372036854775806` | `9223372036854775806` |
|
|
|
|
|
|
|
|
|
|
##### Unix timestamp example
|
|
|
|
|
```js
|
|
|
|
|
myMeasurementName fieldKey="fieldValue" 1556813561098000000
|
|
|
|
|
```
|
|
|
|
|
|
2019-05-06 14:46:18 +00:00
|
|
|
|
## Quotes
|
2019-05-07 02:42:37 +00:00
|
|
|
|
Line protocol supports single and double quotes as described in the following table:
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
| Element | Double quotes | Single quotes |
|
|
|
|
|
| :------ | :------------: |:-------------: |
|
|
|
|
|
| Measurement | _Limited_ <sup class="required">*</sup> | _Limited_ <sup class="required">*</sup> |
|
|
|
|
|
| Tag key | _Limited_ <sup class="required">*</sup> | _Limited_ <sup class="required">*</sup> |
|
|
|
|
|
| Tag value | _Limited_ <sup class="required">*</sup> | _Limited_ <sup class="required">*</sup> |
|
|
|
|
|
| Field key | _Limited_ <sup class="required">*</sup> | _Limited_ <sup class="required">*</sup> |
|
|
|
|
|
| Field value | **Strings only** | Never |
|
|
|
|
|
| Timestamp | Never | Never |
|
|
|
|
|
|
|
|
|
|
<sup class="required">\*</sup> _Line protocol accepts double and single quotes in
|
|
|
|
|
measurement names, tag keys, tag values, and field keys, but interprets them as
|
|
|
|
|
part of the name, key, or value._
|
|
|
|
|
|
|
|
|
|
## Special Characters
|
2019-05-07 02:42:37 +00:00
|
|
|
|
Line protocol supports special characters in [string elements](#string).
|
2019-05-06 14:46:18 +00:00
|
|
|
|
In the following contexts, it requires escaping certain characters with a backslash (`\`):
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|
|
|
|
|
| Element | Escape characters |
|
|
|
|
|
|:------- |:----------------- |
|
|
|
|
|
| Measurement | Comma, Space |
|
|
|
|
|
| Tag key | Comma, Equals Sign, Space |
|
|
|
|
|
| Tag value | Comma, Equals Sign, Space |
|
|
|
|
|
| Field key | Comma, Equals Sign, Space |
|
|
|
|
|
| Field value | Double quote, Backslash |
|
|
|
|
|
|
|
|
|
|
You do not need to escape other special characters.
|
|
|
|
|
|
2019-05-07 02:42:37 +00:00
|
|
|
|
##### Examples of special characters in line protocol
|
2019-05-02 22:58:59 +00:00
|
|
|
|
```sh
|
|
|
|
|
# Measurement name with spaces
|
|
|
|
|
my\ Measurement fieldKey="string value"
|
|
|
|
|
|
|
|
|
|
# Double quotes in a string field value
|
|
|
|
|
myMeasurement fieldKey="\"string\" within a string"
|
|
|
|
|
|
|
|
|
|
# Tag keys and values with spaces
|
|
|
|
|
myMeasurement,tag\ Key1=tag\ Value1,tag\ Key2=tag\ Value2 fieldKey=100
|
|
|
|
|
|
|
|
|
|
# Emojis
|
|
|
|
|
myMeasurement,tagKey=🍭 fieldKey="Launch 🚀" 1556813561098000000
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Escaping backslashes
|
2019-05-07 02:42:37 +00:00
|
|
|
|
Line protocol supports both literal backslashes and backslashes as an escape character.
|
2019-05-02 22:58:59 +00:00
|
|
|
|
With two contiguous backslashes, the first is interpreted as an escape character.
|
|
|
|
|
For example:
|
|
|
|
|
|
2019-06-05 15:21:36 +00:00
|
|
|
|
| Backslashes | Interpreted as |
|
2019-05-02 22:58:59 +00:00
|
|
|
|
|:-----------:|:-------------:|
|
|
|
|
|
| `\` | `\` |
|
|
|
|
|
| `\\` | `\` |
|
|
|
|
|
| `\\\` | `\\` |
|
|
|
|
|
| `\\\\` | `\\` |
|
|
|
|
|
| `\\\\\` | `\\\` |
|
|
|
|
|
| `\\\\\\` | `\\\` |
|
|
|
|
|
|
|
|
|
|
## Comments
|
|
|
|
|
Line protocol interprets `#` at the beginning of a line as a comment character
|
|
|
|
|
and ignores all subsequent characters until the next newline `\n`.
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
# This is a comment
|
|
|
|
|
myMeasurement fieldKey="string value" 1556813561098000000
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Naming restrictions
|
|
|
|
|
Measurement names, tag keys, and field keys cannot begin with an underscore `_`.
|
|
|
|
|
The `_` namespace is reserved for InfluxDB system use.
|
|
|
|
|
|
|
|
|
|
## Duplicate points
|
|
|
|
|
A point is uniquely identified by the measurement name, tag set, and timestamp.
|
2019-05-07 02:42:37 +00:00
|
|
|
|
If you submit line protocol with the same measurement, tag set, and timestamp,
|
2019-05-02 22:58:59 +00:00
|
|
|
|
but with a different field set, the field set becomes the union of the old
|
|
|
|
|
field set and the new field set, where any conflicts favor the new field set.
|