Add data source selector on metrics dashboard to select which Prometheus app should be queried
Problem to solve
Now that we're planning on allowing multiple manual configurations, we need to provide a way for users to select the data source for each dashboard.
Intended users
Users of the metrics dashboard.
Further details
Proposal
Use a dropdown selector for changing data sources (Prometheus instances) in Metrics dashboards.
- We should show description for every option showing the type of configuration (GitLab managed or Manual).
- We will use the name of the configuration if use had set it up
- We will use the API URL if user provided no name for the configuration
- The dropdown will have an option to "Manage data sources" which links to the Prometheus configuration page.
- With multiple auto and manual configurations, we'll have to default to one of the manual configurations when multiple manual configurations are available. The easiest way is to default to the first one alphabetically and the user will have the option to switch to a different data source.
- Data sources will be ordered alphabetically in the dropdown, so users can define names for the data sources in a way that certain data sources appear at the top of the dropdown.
- When there's one data source, the dropdown will still contain an option to "Manage data sources" which takes you to the Prometheus config page.
![]() |
See #10615 (closed) for more details around the feature to create and manage multiple manual Prometheus instances.
Permissions and Security
If we decide to link to the cluster, or to the Prometheus integration settings page, we should consider if the user has permission to open those pages.
Documentation
We should probably document the order of precedence for determining which Prometheus app to use when multiple are available.
If there is a project cluster, group cluster and instance cluster with Prometheus installed, as well as a manually configured Prometheus, the order of precedence is as follows:
Manually configured Prometheus > Project cluster Prometheus > Group cluster Prometheus > Instance cluster Prometheus
Documented at https://docs.gitlab.com/ee/user/project/integrations/prometheus.html#precedence-with-multiple-prometheus-configurations
Availability & Testing
What does success look like, and how can we measure that?
When visiting the Metrics dashboard, it is clear to the user which Prometheus app is being used to display the data.
When visiting the Metrics dashboard, the user can select a data source for the current dashboard.