Welcome to mirror list, hosted at ThFree Co, Russian Federation.

grafana_api_controller.rb « projects « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 85f47b92e586fd412d75c4e998808a9671c121bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

class Projects::GrafanaApiController < Projects::ApplicationController
  include RenderServiceResults
  include MetricsDashboard

  before_action :validate_feature_enabled!, only: [:metrics_dashboard]

  def proxy
    result = ::Grafana::ProxyService.new(
      project,
      params[:datasource_id],
      params[:proxy_path],
      query_params.to_h
    ).execute

    return continue_polling_response if result.nil?
    return error_response(result) if result[:status] == :error

    success_response(result)
  end

  private

  def metrics_dashboard_params
    params.permit(:embedded, :grafana_url)
  end

  def validate_feature_enabled!
    render_403 unless Feature.enabled?(:gfm_grafana_integration)
  end

  def query_params
    params.permit(:query, :start, :end, :step)
  end
end