Running a query

To run a query, you need to send a GET request to a query endpoint. To do this, in the following code, you should specify the target database (mydb) as the value for the db URL parameter and add the query you want to run as the q URL parameter:

curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb" --data-urlencode "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region\"='us-west'"

InfluxDB will return a response in the JSON format, with the results displayed in the results array. In the case of an error, the database will generate an error key, explaining the cause of the error:

{   "results": [       {           "statement_id": 0,           "series": [               {                   "name": "cpu_load_short",                   "columns": [                       "time",                       "value"                   ], "values": [ ...

Get Industrial Internet Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.