Grafana
Connect Grafana to Berserk using the Berserk datasource plugin
The Berserk datasource plugin lets you query Berserk directly from Grafana dashboards using KQL.
Download the latest release for your platform from the GitHub releases page. Archives are available for Linux (x64, ARM64, ARM) and macOS (x64, ARM64).
Installation
Extract the plugin
Unzip the downloaded archive into your Grafana plugins directory:
unzip berserk-datasource-*.zip -d /var/lib/grafana/plugins/Allow unsigned plugin
Since the plugin is not signed, add it to the allow list in your Grafana configuration (grafana.ini or environment variable):
[plugins]
allow_loading_unsigned_plugins = berserk-datasourceOr with an environment variable:
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=berserk-datasourceRestart Grafana
Restart Grafana to load the plugin.
Add the datasource
In Grafana, go to Connections > Data sources > Add data source and search for Berserk. Set the URL to your Berserk query service (default: http://localhost:3001).
Querying
The plugin supports KQL queries. Write your query in the editor and select a dataset from the dropdown. The plugin supports:
- Table format for log and trace data
- Time series for metrics and
summarize ... by bin(Timestamp, ...)queries - Alerting via Grafana alert rules
- Streaming for live tail queries
- Template variables for dynamic dashboards
Time Filter Macros
You must use $__timeFilter in your queries to scope them to the dashboard's selected time range. Without it, queries will scan all data. This restriction will be removed in a future version where the time filter is auto-injected.
The plugin provides macros that are replaced with the dashboard's time range before the query is sent to Berserk:
| Macro | Expands to | Description |
|---|---|---|
$__timeFilter | $time >= datetime(...) and $time <= datetime(...) | Filter on the default $time column |
$__timeFilter(col) | col >= datetime(...) and col <= datetime(...) | Filter on a custom datetime column |
$__timeFrom | datetime(2025-01-01T00:00:00Z) | Start of the selected time range |
$__timeTo | datetime(2025-01-01T06:00:00Z) | End of the selected time range |
$__timeInterval | 5000ms | Recommended bin size based on the time range and panel width |
Use bin_auto($time) to automatically choose a bin size based on the time range, or bin_auto($time, 10m) to set a minimum bin size.
Example Queries
Count events over time by category:
default
| where $__timeFilter
| summarize count() by category, bin_auto($time)
| sort by $timeAverage and p95 latency over time:
default
| where resource.attributes["service.name"] == "my-service"
| where $__timeFilter
| summarize
avg_duration=avg(toint(duration_ms)),
p95_duration=percentile(toint(duration_ms), 95)
by bin_auto($time)
| sort by $timeTop pages by count:
default
| where name == "page_view"
| where $__timeFilter
| summarize count=count() by url.path
| sort by count desc
| take 20Error log table:
default
| where severity >= 3
| where $__timeFilter
| project $time, resource.attributes["service.name"], body, error.message
| sort by $time desc
| take 100Parse structured log messages:
default
| where body contains "throughput"
| where $__timeFilter
| parse tostring(body) with "Local throughput: " Throughput:double " MB" *
| summarize min(Throughput), max(Throughput) by bin_auto($time)