zhaohai666 opened a new pull request, #926:
URL: https://github.com/apache/rocketmq-dashboard/pull/926
# feat(metrics): bundle Grafana dashboards with view & export (METRICS-01)
> Branch: `feature/studio-grafana-dashboards`
> Base: `rocketmq-studio`
> Scope: METRICS-01 — *Built-in Grafana dashboard assets (≥10 JSON
templates)*
## Summary
RocketMQ Studio now ships a curated set of **Grafana dashboard JSON
templates** as bundled
classpath resources. Users can browse the available dashboards, preview the
JSON model, and
export any dashboard as a file to import into their own Grafana instance —
no manual copy
from docs required.
Twelve dashboards are included (≥10 requirement met), each targeting a
distinct RocketMQ
observability domain with PromQL panels on `rocketmq_*` metrics, template
variables for
`cluster` / `broker` / `topic`, and a `rocketmq` tag.
## Bundled dashboards
`rocketmq-overview`, `rocketmq-broker`, `rocketmq-consumer`,
`rocketmq-producer`,
`rocketmq-topic`, `rocketmq-tps`, `rocketmq-storage`, `rocketmq-jvm`,
`rocketmq-threadpool`,
`rocketmq-dlq`, `rocketmq-latency`, `rocketmq-network`
Generation is reproducible via `server/scripts/gen_grafana_dashboards.py`
(schemaVersion 39,
`${DS_PROMETHEUS}` datasource variable).
## Changes
### Backend (`server/.../cluster/metrics/grafana`)
- `GrafanaDashboardInfo` — lightweight metadata record (`uid`, `title`,
`description`, `tags`).
- `GrafanaDashboardService` — loads `classpath*:grafana/*.json` via
`PathMatchingResourcePatternResolver`; `listDashboards()`,
`getDashboard(uid)` (404 if
missing), `getDashboardJson(uid)` (raw JSON string).
- `GrafanaDashboardController` — REST endpoints.
- `server/scripts/gen_grafana_dashboards.py` — generator for the 12 JSON
assets.
- `server/src/main/resources/grafana/*.json` — the 12 dashboard assets.
### Frontend (`web/...`)
- `api/metrics.ts` — added `GrafanaDashboardInfo`, `listGrafanaDashboards`,
`getGrafanaDashboard`, `exportGrafanaDashboard` (blob export).
- `services/grafanaService.ts` — service layer with mock/real data-mode
support.
- `mock/grafanaDashboards.ts` — 12 mock dashboards mirroring the bundled
assets.
- `components/GrafanaDashboardList.tsx` — table + view-modal (renders JSON)
+ export download.
- `pages/studio/GrafanaDashboards.tsx` — page wired into the studio nav.
- `layouts/MainLayout.tsx`, `App.tsx` — navigation entry + lazy route.
- `i18n/translations.ts` — `grafana.*` keys (zh/en).
## API
```
GET /api/metrics/grafana/dashboards # list dashboard metadata
GET /api/metrics/grafana/dashboards/{uid} # full dashboard model (Map)
GET /api/metrics/grafana/dashboards/{uid}/export # raw JSON,
Content-Disposition: attachment
```
## Testing
- **Backend** (`server/src/test/.../cluster/metrics/grafana`):
- `GrafanaDashboardServiceTest` — list ≥10, get model, 404 handling.
- `GrafanaDashboardControllerTest` — WebMvc coverage incl.
`Content-Disposition` on export.
- All pass; Checkstyle clean.
- **Frontend** (`web/src`):
- `api/metrics.test.ts` (grafana cases), `services/grafanaService.test.ts`,
`components/__tests__/GrafanaDashboardList.test.tsx`.
- `tsc --noEmit` clean; ESLint clean.
## Notes / Follow-ups
- Dashboards reference a `${DS_PROMETHEUS}` datasource variable so they
import cleanly into
any Grafana with a Prometheus datasource.
- Export returns `application/json` with an `attachment` disposition for
one-click download.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]