Metrics dashboard - implement selectable data source
Background
To support multiple Prometheus instances connected to single project, we need to enable users selecting one data source from collection of all connected ones, to be used when viewing different metrics dashboards.
Implementation
Currently there are two possible data - sources, PromethuesService
entry, and Clusters::Applications::Prometheus
entry. First is unique per Project
entry (but is carried via Environment
), and second is unique per Cluster
entry. Selecting data source effectively means, selecting either Environment
entry, or Cluster
entry. This can be achieve with usage of GlobalId
For the MVC we should:
- Pass
datasource_id
parameter toEnvironment#metrics
action, than include it indashboard-endpoint
returned byEnvironmentsHelper#project_and_environment_metrics_data
- Pass
datasource_id
parameter throughMetricsDashboard#metrics_dashboard
into::Gitlab::Metrics::Dashboard::Finder
and than into::Gitlab::Metrics::Dashboard::Stages::MetricEndpointInserter
so it can be added to each metricsprometheus_endpoint_path
- Handle
datasource_id
parameter atMetrics::Dashboard::PrometheusApiProxy
so correct entry (either environment of cluster) is selected and handed over toPrometheus::ProxyService
- Handle
datasource_id
parameter atProjects::Prometheus::AlertsController#create
so correct cluster entry is selected to be target ofschedule_prometheus_update!
method
By following that steps we should enable selecting datasource to the users
POC !39352 (closed) demo https://www.youtube.com/watch?v=3ZFSztgGVxw&feature=youtu.be