2020-04-10 14:09:32 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
module Metrics
|
|
|
|
class DashboardResolver < Resolvers::BaseResolver
|
2021-03-11 07:09:28 -05:00
|
|
|
type Types::Metrics::DashboardType, null: true
|
|
|
|
calls_gitaly!
|
|
|
|
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :path, GraphQL::Types::String,
|
2020-04-10 14:09:32 -04:00
|
|
|
required: true,
|
2021-03-16 14:11:53 -04:00
|
|
|
description: <<~MD
|
|
|
|
Path to a file which defines a metrics dashboard eg: `"config/prometheus/common_metrics.yml"`.
|
|
|
|
MD
|
2020-04-10 14:09:32 -04:00
|
|
|
|
|
|
|
alias_method :environment, :object
|
|
|
|
|
2021-03-16 14:11:53 -04:00
|
|
|
def resolve(path:)
|
2020-04-10 14:09:32 -04:00
|
|
|
return unless environment
|
|
|
|
|
2021-03-16 14:11:53 -04:00
|
|
|
::PerformanceMonitoring::PrometheusDashboard.find_for(path: path, **service_params)
|
2021-03-11 07:09:28 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def service_params
|
|
|
|
{
|
|
|
|
project: environment.project,
|
|
|
|
user: current_user,
|
|
|
|
options: { environment: environment }
|
|
|
|
}
|
2020-04-10 14:09:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|