Grafana is a popular observability and monitoring application used to visualize data and help with time-series data analysis. It has an extensive ecosystem of widgets and plugins. QuestDB supports connecting to Grafana via the Postgres endpoint.


  • Grafana should be installed and running.
  • QuestDB should be installed and running via Docker

Start Grafana#

You can start a grafana docker container with this command:

docker run -it --rm --name=grafana -p 3000:3000 grafana/grafana-oss:latest

Add a data source#

  1. Open Grafana's UI (by default available at http://localhost:3000)
  2. Go to the Configuration section and click on Data sources
  3. Click Add data source
  4. Choose the PostgreSQL plugin and configure it with the following settings:
host: <localhost>:8812
database: qdb
user: admin
password: quest
SSL mode: disable
  1. When adding a panel, use the "text edit mode" by clicking the pencil icon and adding a query

localhost will be the IP address reported by QuestDB on startup.

Global variables#

Use global variables to simplify queries with dynamic elements such as date range filters.


This variable allows filtering results by sending a start-time and end-time to QuestDB. This expression evaluates to:

timestamp BETWEEN
'2018-02-01T00:00:00Z' AND '2018-02-28T23:59:59Z'


This variable calculates a dynamic interval based on the time range applied to the dashboard. By using this function, the sampling interval changes automatically as the user zooms in and out of the panel.

Example query#

pickup_datetime AS time,
avg(trip_distance) AS distance
FROM taxi_trips
WHERE $__timeFilter(pickup_datetime)
SAMPLE BY $__interval;

Known issues#

For alert queries generated by certain Grafana versions, the macro $__timeFilter(timestamp) produces timestamps with nanosecond precision, while the expected precision is millisecond precision. As a result, the alert queries are not compatible with QuestDB and lead to an Invalid date error. To resolve this, we recommend the following workaround:

pickup_datetime AS time,
avg(trip_distance) AS distance
FROM taxi_trips
WHERE pickup_datetime BETWEEN cast($__unixEpochFrom()*1000000L as timestamp) and cast($__unixEpochTo()*1000000L as timestamp)

See Grafana issues for more information.

See also#