3.1. Grafana connector#

3.1.1. Introduction#

Official QuasarDB Grafana plugin. It extends QuasarDB’s support to allow integration with the Grafana analytics and monitoring platform. You may read and download the connector’s code from GitHub at https://github.com/bureau14/qdb-grafana-plugin


3.1.2. Prerequisites#

This documentation assumes you have:

  • Grafana installed and running.

  • Both the QuasarDB daemon qdbd and the REST API qdb_rest running.

3.1.3. Installation#

The easiest way to install the plugin is via the Grafana CLI

grafana-cli --pluginUrl https://github.com/bureau14/qdb-grafana-plugin/archive/|version_full|.zip plugins install qdb-grafana-datasource

Alternatively, you can clone the git repository to your Grafana plugins directory (this is usually /var/lib/grafana/plugins on Linuxed-based systems)

cd /var/lib/grafana/plugins
git clone https://github.com/bureau14/qdb-grafana-plugin.git

Finally, restart your Grafana server and the plugin will be added automatically.

3.1.4. Configuration#

Navigate your web browser to Grafana’s datasource configuration, and click Add data source. You will see QuasarDB as one of the available data sources.


It is recommended to leave Access set to Server (Default) unless you specifically know otherwise.

If your cluster is not secured you just need to fill in the REST API URL (default is http://localhost:40080) into the URL field as shown below:


If your cluster is secured make sure to use the secure REST API URL (default is https://localhost:40493) when filling in the URL field.


You may need to check Skip TLS Verify under Auth settings if you are using a self-signed TLS certificate.

Check the Use Secure Cluster checkbox and fill in the User name and User secret fields using the information found in your user private key file as shown below:


After you are done, click Save & Test and you are ready to starting creating visualizations using QuasarDB.

3.1.5. Usage# Quering#

You can add a visualization using QuasarDB by selecting the QuasarDB Data Source when creating a new visualization.

In addition to normal query syntax you can use the $__range and $__interval variables provided by Grafana.

For example the query:

SELECT * FROM measurements IN RANGE(2007, 2008) GROUP BY 1h

Could be written to use Grafana’s variables like this:

SELECT * FROM measurements IN $__range GROUP BY $__interval

For more information on query syntax see our query language reference Query variables#

Query variables enable you to create more interactive and dynamic dashboards by writing a data source query that can return a list of tables, column values, tag values. Query variables support number and string values.

For more information on how to use Grafana variables check official documentation. Adding query variables#

  1. In your dashboard view go to dashboard settings -> variables and click on add new variable.

    ../../_images/add-variable-1.png ../../_images/add-variable-2.png ../../_images/add-variable-3.png
  2. In query options select your QuasarDB datasource

  3. Insert query in Query textbox

  4. Run query to verify results, apply changes.



Query variables are formated as column_name=column_value. This makes it easier to reuse in queries. If no column_name is provided (e.g: when listing tables) query variables are formated as column_value only. Creating query variables using simplified query syntax#

For simpler queires where you want to select distinct values from column you can use simplified query syntax. This reduces the likelihood of errors in queries and speeds up creating simple variables.

For more complex queries you can use your own queries.

Example usage of simplified query syntax in Grafana:


SELECT column FROM table GROUP BY column

can be written as:



Table names containing ., / charactes should be placed inside double quotes.



By default if Include all option checkbox is checked All variable is set to 1=1. Quering using query variables#

Single value variables are replaced with their values.

For example:

Grafana query:

SELECT * FROM measurements WHERE $sensor_id

will be translated to:

SELECT * FROM measurements WHERE sensor_id='sensor1'

You can olso use multiple values of a variable in query by selecting Multi value checkbox when creating it. By default all vaues are joined with OR. You can change this behaviour by including variable inside one of special variables listed below:

  • $__or - splits variables with OR

  • $__and - splits variables with AND

  • $__comma - splits variables with ,


Grafana query:

SELECT * FROM measurements WHERE ${sensor_id}

will be translated to:

SELECT * FROM measurements WHERE (sensor_id='sensor3' OR sensor_id='sensor2')

Grafana query:

SELECT * FROM measurements WHERE $__or($sensor_type)

will be translated to:

SELECT * FROM measurements WHERE (sensor_type='temperature' OR sensor_type='vibration')

Grafana query:

SELECT * FROM $__comma($tables) WHERE $__or($sensor_id)

will be translated to:

SELECT * FROM foo_03, measurements WHERE (sensor_id='sensor2' OR sensor_id='sensor3)