Get CSV data from InfluxDB

Download raw data from InfluxDB in CSV format

Grafana is an amazing visualization tool but sometimes we have to do more complicated offline analysis using e.g. Matlab/Octave or SciPy or Microsoft Excel. For this use-case, it is useful to download raw data in CSV format from InfluxDB. Those CSV data can be easily imported into the data analytics tools. In this short tutorial, I will show you how to do that.

First of all, go to the Corlysis and select your database and click on the “Console” button. Write query “SHOW MEASUREMENTS” to get the list of your measurements (measurement is similar to the SQL table).

show measurements

Now we are going to prepare a query that will give us required data. Web console can show you an only limited number of points so do not write select * from meas_name if you have thousands data points. Please use limit to preview data. In my case, I wrote:

 "select * from rtemp limit 10"

select query

You can also limit data by a time:

select * from rtemp where time >= '2018-03-24T10:20:00Z'

OR select e.g. data that was added in last 100s:

select * from rtemp where time >= now() - 100s

We have prepared query and we will use cURL tool to download that data in CSV format.

$ curl -H "Accept: application/csv" -G ''  --data-urlencode "db=boiler" -u token:YOUR-SECRET-PASSWORD --data-urlencode "q=select * from rtemp where time >= now() - 100s"