2019-10-10 12:06:19 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Projects::GrafanaApiController < Projects::ApplicationController
|
|
|
|
include RenderServiceResults
|
2019-10-31 15:06:41 +00:00
|
|
|
include MetricsDashboard
|
|
|
|
|
2019-10-10 12:06:19 +00:00
|
|
|
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
|
|
|
|
|
2019-10-31 15:06:41 +00:00
|
|
|
def metrics_dashboard_params
|
|
|
|
params.permit(:embedded, :grafana_url)
|
|
|
|
end
|
|
|
|
|
2019-10-10 12:06:19 +00:00
|
|
|
def query_params
|
|
|
|
params.permit(:query, :start, :end, :step)
|
|
|
|
end
|
|
|
|
end
|