documentation/integrations/visualization/grafana.md
import Screenshot from "@theme/Screenshot"
Grafana is a popular observability and monitoring application used to visualize data and enable time-series data analysis.
QuestDB is available within Grafana via the official QuestDB plugin.
:::warning QuestDB can also be used with the PostgreSQL Grafana plugin, but the configuration options are different in that case. The QuestDB official plugin is strongly recommended instead. :::
For a walk-through style guide, see our blog post.
--add-host parameter for both Grafana and QuestDB.Start Grafana using docker run:
docker run --add-host=host.docker.internal:host-gateway \
-p 3000:3000 --name=grafana \
-v grafana-storage:/var/lib/grafana \
grafana/grafana-oss
Once the Grafana server has started, you can access it via port 3000
(http://localhost:3000). The default login credentials
are as follows:
user:admin
password:admin
The Docker version runs on port 8812 for the database connection and port
9000 for the Web Console and REST interface:
docker run --add-host=host.docker.internal:host-gateway \
-p 9000:9000 -p 9009:9009 -p 8812:8812 -p 9003:9003 \
-v "$(pwd):/var/lib/questdb" \
-e QDB_PG_READONLY_USER_ENABLED=true \
questdb/questdb:latest
http://localhost:3000)Server Address is the host address without the port. Some common values are host.docker.internal when using Docker on the same host, localhost when running standalone Grafana on the same host, or the QuestDB instance IP address when running Grafana remotely.8812 is passed as a separate parameter.disable. This can be left empty for QuestDB Enterprise.Server address: host.docker.internal
Server port: 8812
Username: user
Password: quest
TLS/SSL mode: disable
Toggle the Query Builder to SQL Editor by clicking the button.
Write SQL queries!
<Screenshot alt="Screenshot of a blank panel after being created" src="images/blog/2023-04-12/blank-panel.webp" jumbo={true} />
By default, Grafana limits the maximum refresh rate of your dashboards. The maximum default rate is to refresh every 5 seconds. This is to provide relief to the database under-the-hood. However, with QuestBD's significant performance optimizations, we can lower this rate for greater fluidity.
To learn how, see our blog post.
Use global variables to simplify queries with dynamic elements such as date range filters.
$__timeFilter(timestamp)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'
$__intervalThis 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.
SELECT
timestamp AS time,
avg(price) AS avg_price
FROM trades
WHERE $__timeFilter(timestamp)
SAMPLE BY $__interval;