TL;DR InfluxDB Tech Tips - Sorting Timestamps In Query Results & Quoting In Line Protocol
By
Regan Kuchan /
Developer
Sep 22, 2016
Navigate to:
In this weekly post we recap the most interesting InfluxDB how to sort timestamps in query results and quoting in line protocol, workarounds, and Q&A from GitHub, IRC and the InfluxDB Google Group that you might have missed in the last week or so.
Sorting timestamps in query results
Q: Is there a way to make my timestamps return in reverse order? That is, instead of returning the points with the oldest timestamps first return the points with the newest timestamps first?
A: Yes - append ORDER BY time DESC to your query.
Without ORDER BY time DESC:
> SELECT * FROM "upside_down"
name: upside_down
-----------------
time cake
2016-09-21T20:00:00Z 1
2016-09-21T20:10:00Z 2
2016-09-21T20:20:00Z 4
With ORDER BY time DESC:
> SELECT * FROM "upside_down" ORDER BY time DESC
name: upside_down
-----------------
time cake
2016-09-21T20:20:00Z 4
2016-09-21T20:10:00Z 2
2016-09-21T20:00:00Z 1
Quoting in line protocol
Q: I’m able to successfully write data to InfluxDB but my queries return no results. Am I doing something wrong?
> INSERT "where_are_you" value=700
>
> SELECT * FROM where_are_you
>
> SELECT * FROM "where_are_you"
>
A: When you double quote the measurement in line protocol InfluxDB assumes that the quotes are part of the measurement name. To query data in “where_are_you” you’ll need to both double quote the measurement name and escape the double quotes that are part of the measurement name:
> SELECT * FROM "\"where_are_you\""
name: "where_are_you"
---------------------
time value
2016-09-21T23:16:13.571616685Z 700
In general, we recommend that you avoid double quoting measurements, tag keys, tag values, and field keys in line protocol. See Frequently Encountered Issues for more on when to double and single quote in line protocol.
Meetup video
Check out the video from the SF InfluxDB Meetup in August to get tips on GROUP BY time() queries, continuous queries, and more.
For more InfluxDB tips, see our Frequently Encountered Issues page and feel free to post your questions in the InfluxDB users group!
What's next?
- Download and get started with InfluxDB!
- Schedule a FREE 20 minute consultation with a Solutions Architect to review your InfluxDB project.
- Attend one of our FREE virtual training seminars.
- Got a question and need an immediate answer from the InfluxData Support team? Support subscriptions with unlimited incidents start at just $399 a month. Check out all the support options here.