Grafana Integration
Visualize your time series data with Grafana dashboards. MynaDB integrates seamlessly with Grafana through multiple datasource options, including InfluxDB-compatible endpoints, native SQL via the MySQL protocol, and a built-in monitoring dashboard for operational visibility.
Datasource Setup
Follow these steps to connect Grafana to MynaDB using the InfluxDB datasource plugin:
-
Open Grafana and navigate to datasources
Go to Configuration → Data Sources → Add data source in your Grafana instance. -
Select the InfluxDB datasource type
Search for InfluxDB in the datasource list and select it. MynaDB exposes InfluxDB-compatible query endpoints. -
Configure the connection URL
Set the URL to your MynaDB instance HTTP address:texthttp://your-mynadb-host:7000 -
Set the database name
Enter your database (catalog) name in the Database field. This corresponds to the:dbparameter used in MynaDB write and query endpoints (e.g.,mydb). -
Configure authentication (if enabled)
If MynaDB authentication is enabled, toggle Basic Auth and provide the username and password configured in yourconfig.tomlunder[auth]. -
Save and test
Click Save & Test. Grafana will verify the connection to MynaDB.
InfluxDB-Compatible Endpoints
MynaDB exposes several query endpoints that Grafana can use depending on your preferred query language:
| Endpoint | Protocol | Description |
|---|---|---|
/api/v2/query |
Flux | InfluxDB v2-compatible Flux query endpoint. Use this when Grafana is configured with the InfluxDB datasource in Flux mode. |
/api/v1/query |
InfluxQL | InfluxDB v1-compatible InfluxQL query endpoint. Suitable for legacy dashboards or simpler query syntax. |
/query/:db |
Native SQL | MynaDB native SQL endpoint powered by Apache DataFusion. Provides the full power of SQL including JOINs, window functions, and CTEs. |
Built-in Dashboard
MynaDB ships with a Grafana-style monitoring dashboard accessible from the Admin Console. This built-in dashboard provides real-time operational visibility without requiring a separate Grafana installation.
The dashboard includes the following panels:
- Ingestion Rate — Tracks the number of points written per second, broken down by database and measurement. Helps identify write throughput bottlenecks and traffic spikes.
- Query Latency — Displays p50, p95, and p99 query execution times. Monitors query performance over time and highlights slow queries that may need optimization.
- Storage Size — Shows total disk usage across all catalogs and schemas, with a breakdown by compaction level (L0, L1, L2). Useful for capacity planning and tracking data growth.
- Compaction Progress — Visualizes active compaction jobs, files merged, bytes reclaimed, and compaction backlog. Ensures background maintenance is keeping up with write volume.
Access the built-in dashboard at:
http://your-mynadb-host:7000/admin/dashboard
Example Queries in Grafana
When using Grafana with MynaDB's native SQL endpoint, you can use Grafana's built-in template variables to create dynamic, time-aware dashboards. Below are common query patterns.
Time-filtered aggregation
SELECT
time_bucket('$__interval', time) AS time,
avg(cpu_usage) AS avg_cpu,
max(cpu_usage) AS max_cpu
FROM mydb.default.system_metrics
WHERE $__timeFilter(time)
GROUP BY time_bucket('$__interval', time)
ORDER BY time
Multi-host comparison
SELECT
time_bucket('$__interval', time) AS time,
host,
avg(memory_used_percent) AS avg_memory
FROM mydb.default.system_metrics
WHERE $__timeFilter(time)
AND host IN ($host)
GROUP BY time_bucket('$__interval', time), host
ORDER BY time
Ingestion rate monitoring
SELECT
time_bucket('$__interval', time) AS time,
count(*) / EXTRACT(EPOCH FROM INTERVAL '$__interval') AS points_per_second
FROM mydb.default.measurements
WHERE $__timeFilter(time)
GROUP BY time_bucket('$__interval', time)
ORDER BY time
Top-N query with variable
SELECT
host,
avg(cpu_usage) AS avg_cpu,
max(cpu_usage) AS peak_cpu
FROM mydb.default.system_metrics
WHERE $__timeFilter(time)
GROUP BY host
ORDER BY avg_cpu DESC
LIMIT $topN
The following Grafana macros are supported:
| Macro | Description | Example Expansion |
|---|---|---|
$__timeFilter(time) |
Expands to a time range filter based on the dashboard's selected time range | time >= 1704067200000000000 AND time <= 1704153600000000000 |
$__interval |
Auto-calculated aggregation interval based on the dashboard time range and panel width | 1m, 5m, 1h |
$__from / $__to |
Start and end timestamps of the selected dashboard time range | 1704067200000 |
MySQL Datasource Alternative
As an alternative to the InfluxDB datasource, you can connect Grafana to MynaDB using the MySQL datasource. MynaDB implements the MySQL wire protocol on port 7002, allowing standard MySQL clients and tools (including Grafana) to execute SQL queries directly.
Setup steps
-
Enable MySQL protocol in MynaDB
Ensure the MySQL protocol is enabled in yourconfig.toml:toml[server] mysql_enabled = true mysql_port = 7002 -
Add a MySQL datasource in Grafana
Go to Configuration → Data Sources → Add data source and select MySQL. -
Configure the connection
text
Host: your-mynadb-host:7002 Database: mydb User: admin (if auth is enabled) Password: secret (if auth is enabled) -
Save and test the connection
Click Save & Test to verify connectivity.
Advantages of the MySQL datasource
- Full SQL support including JOINs, subqueries, CTEs, and window functions
- Native Grafana SQL query editor with autocomplete
- Compatible with Grafana alerting rules
- No additional plugin installation required
Example MySQL datasource query
SELECT
UNIX_TIMESTAMP(time) AS time_sec,
avg(value) AS avg_value,
measurement
FROM cpu
WHERE time BETWEEN FROM_UNIXTIME($__from / 1000) AND FROM_UNIXTIME($__to / 1000)
GROUP BY time_bucket('$__interval', time), measurement
ORDER BY time_sec