Syntax tips

Syntax is always a challenge to remember, so here's a guide:


When writing to the database using the line protocol:

  • all writes must have a target database in the query string. E.g. 

curl ... localhost:8086/write?db=mydb ...

  • never quote measurement names (they are always strings)
  • always escape commas and whitespace in measurement names
  • never quote tag keys or values (they are always strings)
  • always escape commas and whitespace in tag keys and values
  • never quote field keys (they are always strings)
  • always escape commas and whitespace in field keys
  • if your field value is a(n):
    • integer - don't use a decimal point (1, not 1.0)
    • float - you must use a decimal point (1.0, not 1)
    • string - always double-quote ("")
    • boolean - use any of the following, unquoted: [t, T, true, True, TRUE; f, F, false, False, FALSE]
  • if you provide timestamps in any unit other than nanoseconds, you must supply the appropriate precision in the URL query string. E.g. for milliseconds:

curl ... localhost:8086/write?precision=ms ...

use [n, u, ms, s, m, h] for nanoseconds, microseconds, milliseconds, seconds, minutes, and hours, respectively. If no `precision` is supplied, nanoseconds is assumed.

 When querying the database:

  • All measurement names, tag keys, and field keys must be double-quoted if they contain a character other than [A-Z,a-z,0-9,_] or if they begin with a digit
  • Any measurement name, tag key, or field key that matches a query language identifier (e.g. SELECT, INSERT, FROM, time, etc.) must be double-quoted whenever used in a query.
  • All tag values must be single-quoted
  • Field values must be single-quoted if they are strings
Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk