neiam
/grafana-plasmoid
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
Log in to mark this repository.
| .forgejo | |||
| contents | |||
| packaging | |||
| tools | |||
| .gitignore | 201 B | ||
| LICENSE.md | 34.1 KiB | ||
| metadata.json | 736 B | ||
| package.sh | 2.7 KiB | ||
| README.md | 6.8 KiB |
Grafana Dashboards Widget for Plasma 6
A Plasma 6 widget that draws your Grafana dashboards as native Qt widgets, not an embedded browser, and keeps a few chosen values in the panel.
[▣] git rps git p95 pg down
7.95 406 ms 9
- Logo: opens the popup on the last dashboard you viewed.
- Pinned values: any panel’s first series, reduced the way that panel reduces it (last, mean, max…), formatted with its unit and coloured by its thresholds. Hover a value for every series. Click it to open its dashboard.
- On the desktop the widget is the dashboard itself, refreshing on its own.
What’s drawn
Panels sit on Grafana’s 24-column grid. If the widget is too narrow for that, they stack full-width in reading order, like Grafana’s mobile layout.
| Panel | Native rendering |
|---|---|
| Time series / graph | Lines, area (incl. opacity gradients), bars, points; normal & percent stacking; step interpolation; null gaps; threshold lines/areas; hover crosshair + tooltip (single/multi, sorted); legend with calcs, click to isolate, ctrl-click to toggle |
| Stat | One tile per series, colorMode value / background / none, textMode, sparkline |
| Gauge | 240° arc with threshold ring |
| Bar gauge | Basic, gradient and LCD bars, horizontal or vertical |
| Table | Instant queries joined into Value #A/#B/… columns per label set, or a frame’s own columns. Applies displayName, unit and color-text/color-background overrides. Click a header to sort |
| Text | Markdown or HTML, with variables |
| Pie chart | Pie or donut |
Rows fold and unfold. A folded row’s panels aren’t queried until you open it. Library panels are resolved. Repeated panels (repeat: $var, horizontal or vertical, maxPerRow) get one copy per value. Anything else shows a View in Grafana button. Every panel has one too on hover.
Field config goes through the panel’s overrides: byName, byRegexp and byFrameRefID. Colours follow palette-classic, fixed, thresholds and the continuous-* schemes, using Grafana’s named colours. Supported units include short, percent/percentunit, bytes/decbytes/bits, Bps/bps, reqps/ops/rps, time durations (ns…d), °C/°F, Hz and currency. Custom suffix:/prefix: units also work.
Variables
The bar above the dashboard has a picker for each visible variable.
- Prometheus query variables are evaluated live through the datasource:
label_values(metric, label),label_values(label),label_names(),metrics(re)andquery_result(expr). Each variable can depend on the ones before it, and the variable’s ownregexandsortare applied. - Custom, interval, datasource and constant variables are supported too.
- Multi-value variables keep the menu open while you tick several. All expands to the full option list, or to
allValue.
Your picks are remembered per dashboard. Values are interpolated the way Grafana’s Prometheus and Loki datasources do it: multi-values are regex-joined, escaped for a regex inside a PromQL string. Grafana’s own $__interval/$__rate_interval/$__range macros are left for the datasource backend to fill in.
Configuration
General
- Grafana URL, e.g.
https://grafana.example.com. A sub-path install is fine. - Service account token: under Administration → Users and access → Service accounts, create one with the Viewer role and add a token (
glsa_…). The widget only reads. - Test Connection: calls
/api/healthand/api/user. - Dashboards: list what’s on the server, filter by title, folder or tag, and add. Reorder with ↑/↓. The popup’s drop-down switches between them.
Pinned
Pick a dashboard, then Pin any of its panels. Each pin can have a short label that replaces the panel title above the value.
Behavior
| Setting | Default | |
|---|---|---|
| Time range | dashboard’s own | Or a fixed now-15m … now-30d for every dashboard. Also switchable from the popup |
| Refresh every | dashboard’s own | Its refresh setting, at least 10 s. Only the dashboard on screen refreshes |
| Pinned values every | 60 s | |
| Grid row height | 30 px | Grafana’s own unit; smaller fits more in the popup |
API
Everything goes through Grafana’s own HTTP API with Authorization: Bearer <token>:
/api/frontend/settings |
datasources by name/uid, for resolving ${ds}-style datasource variables |
/api/search?type=dash-db |
the dashboard picker |
/api/dashboards/uid/:uid |
dashboard JSON (classic schema) |
/api/library-elements/:uid |
library panels |
/api/datasources/uid/:uid/resources/api/v1/… |
Prometheus label values for query variables |
POST /api/ds/query |
one request per panel, all panels on one shared time range; at most 6 in flight |
Requests have their own watchdog, since QML’s XMLHttpRequest ignores timeouts. A resume from suspend drops anything in flight and starts over.
Checking against a real instance
contents/ui/Grafana.js holds all the logic that isn’t drawing: time ranges, variables, query building, frames → series, reducers, units, colours, tables and layout. It’s plain JavaScript, so tools/check.mjs runs every panel of every dashboard through it from node and prints what each would show:
printf 'GRAFANA_URL=http://localhost:3000\nGRAFANA_TOKEN=glsa_...\n' > .env # gitignored
node tools/check.mjs # every dashboard
node tools/check.mjs git-gud waxx # just these
Install
./package.sh --install # installs, or upgrades after changes
systemctl --user restart plasma-plasmashell # Plasma holds the old QML until then
./package.sh 0.1.0 # release archive
Test without installing:
plasmoidviewer -c org.kde.panel -a . -f horizontal -l topedge
plasmoidviewer -a . -f planar -s 1400x1000 # as a desktop dashboard
License
GPL-3.0. See LICENSE.md.