diff options
author | Sarah Yasonik <syasonik@gitlab.com> | 2019-05-01 10:16:03 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-05-01 10:16:03 +0000 |
commit | 552a3d2fd939d3f8a56cfad9fad62227c1d5aa89 (patch) | |
tree | d10ce5f4615b0e9dbeb7543736984b3e3ff10dbb /app/controllers/projects | |
parent | d7b75b661f8ed2468a322c4ae55eadcbdb3b2615 (diff) | |
download | gitlab-ce-552a3d2fd939d3f8a56cfad9fad62227c1d5aa89.tar.gz |
Update metrics dashboard API to load yml from repo
Updates the EnvironmentController#metrics_dashboard endpoint
to support a "dashboard" param, which can be used to specify
the filepath of a dashboard configuration from a project
repository. Dashboard configurations are expected to be
stored in .gitlab/dashboards/.
Updates dashboard post-processing steps to exclude custom
metrics, which should only display on the system dashboard.
Diffstat (limited to 'app/controllers/projects')
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 4aa572ade73..d8812c023ca 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -13,6 +13,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController before_action only: [:metrics, :additional_metrics, :metrics_dashboard] do push_frontend_feature_flag(:metrics_time_window) push_frontend_feature_flag(:environment_metrics_use_prometheus_endpoint) + push_frontend_feature_flag(:environment_metrics_show_multiple_dashboards) end def index @@ -158,15 +159,28 @@ class Projects::EnvironmentsController < Projects::ApplicationController end def metrics_dashboard - return render_403 unless Feature.enabled?(:environment_metrics_use_prometheus_endpoint, @project) + return render_403 unless Feature.enabled?(:environment_metrics_use_prometheus_endpoint, project) - result = Gitlab::Metrics::Dashboard::Service.new(@project, @current_user, environment: environment).get_dashboard + if Feature.enabled?(:environment_metrics_show_multiple_dashboards, project) + result = dashboard_finder.find(project, current_user, environment, params[:dashboard]) + + result[:all_dashboards] = project.repository.metrics_dashboard_paths + else + result = dashboard_finder.find(project, current_user, environment) + end respond_to do |format| if result[:status] == :success - format.json { render status: :ok, json: result } + format.json do + render status: :ok, json: result.slice(:all_dashboards, :dashboard, :status) + end else - format.json { render status: result[:http_status], json: result } + format.json do + render( + status: result[:http_status], + json: result.slice(:all_dashboards, :message, :status) + ) + end end end end @@ -211,6 +225,10 @@ class Projects::EnvironmentsController < Projects::ApplicationController params.require([:start, :end]) end + def dashboard_finder + Gitlab::Metrics::Dashboard::Finder + end + def search_environment_names return [] unless params[:query] |