zhaohai666 opened a new pull request, #1011:
URL: https://github.com/apache/rocketmq-dashboard/pull/1011
## Title (keep or adjust)
[Studio] feat(metrics): support multiple Prometheus-compatible metrics
backends (METRICS-01)
## Summary
Adds support for querying metrics from multiple Prometheus-compatible
backends
(**Prometheus, VictoriaMetrics, Thanos, Mimir, Cortex, ARMS**) through a
shared
abstraction, and exposes a single query endpoint that reuses the **existing**
`SettingsService` data-source stack (MySQL-backed `rmq_data_source` table)
rather
than introducing a second, parallel configuration path.
This version is a **rework** in response to review feedback.
## Rework notes (addressing review)
### ✅ Removed the parallel in-memory persistence path
- Deleted `InMemoryMetricsDataSourceRepository`, the
`MetricsDataSourceRepository`
interface, `MetricsDataSourceService`, and the standalone
`MetricsDataSourceController` (`/api/metrics/datasources`), plus their
tests.
- Deleted the second frontend page (`MetricsDataSources.tsx`), its service
(`metricsService.ts`), the `MetricsDataSourceManager` component, and the
mock
data.
- Data sources are now read from the **existing** MySQL-backed
`rmq_data_source`
store via `SettingsService`, consistent with the trunk persistence
architecture
(#746, #955). No in-memory repository is reintroduced.
### ✅ Multi-backend abstraction kept, aligned to the existing stack
- `PrometheusMetricsSource` now extends the new
`AbstractPrometheusCompatibleMetricsSource` (shared query/parse/auth;
backends
differ only in URL path + `MetricsBackendType`).
- Added `MetricsSourceFactory` that selects the implementation by provider
type,
reusing the existing `MetricsSource` interface.
- The new query endpoint `POST /api/metrics/query/datasource` is added to the
**existing** `MetricsController` (no new controller). It resolves the
configured
data source via `SettingsService.getDataSource(key)` and builds the
`MetricsSource` through the factory.
### ✅ MySQL persistence + existing data-source flow reused
- `SettingsService` now validates and connectivity-tests **cortex** and
**arms**
in addition to prometheus/victoriametrics/thanos/mimir.
- Added `SettingsService.getDataSource(key)` and
`MetricsService.queryByDataSource(...)`.
### ✅ Credentials handled safely (no leak)
- Credentials are supplied **per request** via the new
`MetricsDataSourceQueryRequest` DTO (`username` / `password` /
`bearerToken`)
and are **never persisted**, mirroring the existing `testDataSource` flow.
- This avoids leaking credentials through `GET /api/settings/datasources`,
which
returns `DataSourceVO` directly — so no credential fields were added to
`DataSourceVO`.
## Changed files (17, +1144 / -260)
- Added: `AbstractPrometheusCompatibleMetricsSource`, `ArmsMetricsSource`,
`CortexMetricsSource`, `MimirMetricsSource`, `ThanosMetricsSource`,
`VictoriaMetricsMetricsSource`, `MetricsBackendType`,
`MetricsSourceFactory`,
`MetricsSourceSettings`, `MetricsDataSourceQueryRequest` (request DTO).
- Changed: `PrometheusMetricsSource` (now extends the abstraction),
`MetricsService` (`queryByDataSource`), `MetricsController`
(`POST /query/datasource`), `SettingsService` (cortex/arms +
`getDataSource`).
- Tests: `MetricsServiceTest` (+2 cases), `MetricsBackendTypeTest`,
`MultiBackendMetricsSourceTest`.
## Verification
- `server` module compiles clean (`mvn -o -q compile`).
- Metrics + Settings tests green: `MetricsServiceTest`,
`MetricsBackendTypeTest`,
`MultiBackendMetricsSourceTest`, `SettingsServiceTest` — 52 tests passing.
## How to reopen / update
1. Open https://github.com/apache/rocketmq-dashboard/pull/925
2. Click **Reopen** (the branch head already points to the reworked commit
`088be4a`); the diff will show only the rework commit.
3. Replace the PR description with the text above.
4. (Optional) Rename the title if desired.
--
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]