X-LightYear opened a new issue, #4990:
URL: https://github.com/apache/rocketmq-dashboard/issues/4990

   ## Problem
   
   The metrics data-source contract documents an empty `instanceIds` list as a 
globally available data source. The normal data-source query path honors that 
contract, and the Metrics Explorer labels such a source as `Global`.
   
   The instance-scoped MCP metrics path does not. 
`MetricsService.queryInstance` filters `SettingsService.listDataSources()` to 
sources whose `instanceIds` explicitly contain the requested instance. A sole 
global source is therefore treated as if no source were configured and the 
request fails with HTTP 409.
   
   ## Reproduction
   
   1. Configure one Prometheus-compatible data source with an empty 
`instanceIds` list.
   2. Invoke the instance-scoped metrics tool for any configured instance, for 
example `instance-a`.
   3. The tool reaches `MetricsService.queryInstance("instance-a", query)`.
   
   Minimal deterministic regression setup:
   
   ```java
   DataSourceVO global = dataSource("ds-global", List.of());
   when(settingsService.listDataSources()).thenReturn(List.of(global));
   when(settingsService.getDataSource("ds-global")).thenReturn(global);
   
when(metricsSourceFactory.create(any(MetricsDataSourceConfig.class))).thenReturn(metricsSource);
   
when(metricsSource.query(any(MetricQueryDTO.class))).thenReturn(emptyMetricData());
   
   metricsService.queryInstance("instance-a", rawQuery());
   ```
   
   On current `rocketmq-studio`, this throws:
   
   ```text
   Configure exactly one metrics data source bound to Instance instance-a
   ```
   
   ## Expected behavior
   
   A sole global data source should be selected for an instance-scoped query, 
subject to the same ambiguity and authentication checks as an explicitly shared 
source.
   
   ## Actual behavior
   
   Global sources are excluded before source selection, so the instance-scoped 
query fails even though the source is intentionally configured for all 
instances.
   
   ## Root cause
   
   `MetricsService.queryInstance` defines `boundSources` using only 
`source.getInstanceIds().contains(instanceId)`. It omits the existing 
global-source semantics (`null` or empty bindings) used by 
`validateInstanceBinding` and the web data-source selector.
   
   ## Scope
   
   The minimal fix is limited to the source-selection predicate in 
`MetricsService.queryInstance`, plus deterministic service-level regression 
coverage. Explicit instance bindings and ambiguity behavior should remain 
unchanged.
   
   ## Duplicate check
   
   Historical #1260/#1178 and merged PR #1373 established instance binding 
enforcement and explicitly preserved unbound data sources as globally 
available. They cover the direct data-source query path and do not cover the 
MCP `queryInstance` selector, which still excludes global sources.
   


-- 
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]

Reply via email to