Grafana
Grafana is a popular observability and monitoring application used to visualize data and has an extensive ecosystem of widgets and plugins. QuestDB supports connecting to Grafana via the Postgres endpoint. There's also a complete tutorial that shows you how to use QuestDB with Grafana step by step.
Prerequisites#
- Grafana should be installed and running.
- QuestDB should be installed and running via Docker, the binaries or Homebrew for macOS users.
Configure database#
To avoid unnecessary memory usage, it is recommended to disable QuestDB's SELECT
query cache by setting the property pg.select.cache.enabled=false in your
server.conf. That's because Grafana does not use prepared statements when
sending the queries and the query cache becomes much less efficient.
Add a data source#
- Open Grafana's UI (by default available at
http://localhost:3000) - Go to the
Configurationsection and click onData sources - Click
Add data source - Choose the
PostgreSQLplugin and configure it with the following settings:
- When adding a panel, use the "text edit mode" by clicking the pencil icon and adding a query
Global variables#
To simplify queries which have dynamic elements such as date range filters, the query can contain global variables which are documented in the Grafana reference documentation.
$__timeFilter(timestamp)#
This variable allows filtering results by sending a start-time and end-time to QuestDB. This expression evaluates to:
$__interval#
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#
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:
See Grafana issues for more information.