Table Of Contents

5.10. quasardb rest api

5.10.1. Introduction

The quasardb rest api, qdb_rest, provides a way to communicate with a cluster in the form of json objects.

Notably it can run queries and translate them to json.

5.10.2. Quick Reference

Option Usage Default
-h, --help Show this help message  
--config-file Config file to setup the rest-api  
--cluster URI of the cluster we connect to  
--cluster-public-key-file Key file used for logging  
--log-file File we log to  
--assets-dir Directory we make publicly available  
--host IP to listen on localhost
--port Port to listen on 40000
--tls-host IP to listen on for tls localhost
--tls-port Port to listen on for tls 40000
--tls-certificate Certificate used for tls secure connection  
--tls-key Private key used for tls secure connection  

5.10.3. Run

/path/to/qdb_rest --config-file my-config-file.json

Example of config file:

{
    "allowed_origins": [],
    "cluster_uri": "qdb://127.0.0.1:2836",
    "cluster_public_key_file": "/usr/share/qdb/cluster_public.key",
    "tls_certificate": "/etc/qdb/qdb_rest.cert.pem",
    "tls_key": "/etc/qdb/qdb_rest.key.pem",
    "host": "localhost",
    "port": 40000,
    "log": "/var/log/qdb/qdb_rest.log",
    "assets": "/var/lib/qdb/assets"
}

qdb_rest is either run secured or unsecured, there is no middle ground.

Meaning if you have a tsl_certificate and tls_key it will use https, in the other case it will just use http.

It is mandatory to set tls_certificate and tls_key to connect to a secured cluster. To do so you will also need to set the cluster_public_key_file.

Warning: The assets is what is used to create the dashboard, if you override the asset directory it will replace dashboard with your assets.

5.10.4. Commands

Provided your cluster is secured and you have a private key file for your user. Let’s call this key file tintin.private

Login:

TOKEN=`curl -k -H 'Origin: http://0.0.0.0:3449'  -H "Content-Type: application/json" -X POST --data-binary @tintin.private https://127.0.0.1:40000/api/login`

Get cluster information:

curl -k -H "Authorization: Bearer ${TOKEN}" -H 'Origin: http://0.0.0.0:3449' -i https://localhost:40000/api/cluster

Get node information:

curl -k -H "Authorization: Bearer ${TOKEN}" -H 'Origin: http://0.0.0.0:3449' -i http://127.0.0.1:40000/api/cluster/nodes/127.0.0.1:2836

Run a query:

curl -k -H "Authorization: Bearer ${TOKEN}" -H 'Origin: http://0.0.0.0:3449' -sb -X POST -H "Content-Type: application/json" -d '"select count(*) from timeseries in range (2017,+1y)"' http://127.0.0.1:40000/api/query

5.10.5. Configuration

5.10.6. Options

-h, --help

Displays basic usage information.

--config-file

Config file to setup the rest-api.

--cluster

The cluster uri used for connection.

--cluster-public-key-file

The cluster public key file used for authentication through the logging phase in the dashboard. It works in parallel with a user private key.

--log-file

The file we use for logging purposes.

--assets-dir

The assets directory is made available online at the address https://host:port/index.html If you replace it the dashboard will no longer be available.

--host

IP to listen on

Default value:
localhost
--port

Port to listen on

Default value:
40000
--tls-host

IP to listen on for tls

Default value:
localhost
--tls-port

Port to listen on for tls

Default value:
40000
--tls-certificate

Certificate used for tls secure connection

--tls-key

Private key used for tls secure connection

arrow_backPrevious
5.9. quasardb for Excel
Next arrow_forward
5.11. quasardb dashboard