The open-source platform for monitoring and observability.
Grafana allows you to query, visualize, alert on and understand your metrics no matter where they are stored. Create, explore, and share dashboards with your team and foster a data-driven culture.
-- From Grafana Project
Create a Databend User
Connect to Databend server with BendSQL:
Welcome to BendSQL.
Trying connect to localhost:8000 as user root.
Connected to DatabendQuery v1.1.2-nightly-8ade21e4669e0a2cc100615247705feacdf76c5b(rust-1.70.0-nightly-2023-04-15T16:08:52.195357424Z)
Create a user:
CREATE USER grafana IDENTIFIED BY 'grafana_password';
Grant privileges for the user:
GRANT SELECT ON *.* TO grafana;
Please refer Grafana Installation
Install Grafana Datasource Plugin
Go to grafana plugin page: https://grafana.yourdomain.com/plugins.
Altinity plugin for ClickHouse, click install.
Go to grafana datasource page: https://grafana.yourdomain.com/datasources.
Add data source, select previously installed source type
Altinity plugin for ClickHouse.
Configure the datasource:
HTTP -> URLYour databend query clickhouse endpoint, for example:
Auth -> Basic authenabled
Basic Auth Details -> User, Passwordpreviously created grafana user
Additional -> Use POST method to send queriesenabled
For Databend Cloud users, use the endpoint in
connect, for example:
Save & Testto verify datasource working.
Graphing with Databend
Here we use an existing
nginx.access_logs as an example:
CREATE TABLE `access_logs` (
Create a new dashboard with a new panel, select the Datasource created in previous step.
FROMwith database & table and click
Go to Query:
Input the query with some template variables:
(to_int64(timestamp) div 1000000 div $interval * $interval) * 1000 as t, status,
count() as qps
WHERE timestamp >= to_datetime($from) AND timestamp <= to_datetime($to)
GROUP BY t, status
ORDER BY ttip
You can click
Show Helpfor available macros, some frequently used are:
$intervalreplaced with selected "Group by time interval" value (as a number of seconds)
$tablereplaced with selected table name from Query Builder
$fromreplaced with (timestamp with ms)/1000 value of UI selected "Time Range:From"
$toreplaced with (timestamp with ms)/1000 value of UI selected "Time Range:To"
Then you should be able to see the graph showing:
Adding more panels with this step, we could then have an example dashboard: