2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
module Metrics
|
|
|
|
class DashboardResolver < Resolvers::BaseResolver
|
2021-04-17 20:07:23 +05:30
|
|
|
type Types::Metrics::DashboardType, null: true
|
|
|
|
calls_gitaly!
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :path, GraphQL::Types::String,
|
2020-04-22 19:07:51 +05:30
|
|
|
required: true,
|
2021-04-29 21:17:54 +05:30
|
|
|
description: <<~MD
|
|
|
|
Path to a file which defines a metrics dashboard eg: `"config/prometheus/common_metrics.yml"`.
|
|
|
|
MD
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
alias_method :environment, :object
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
def resolve(path:)
|
2023-07-09 08:55:56 +05:30
|
|
|
return if Feature.enabled?(:remove_monitor_metrics)
|
2020-04-22 19:07:51 +05:30
|
|
|
return unless environment
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
::PerformanceMonitoring::PrometheusDashboard.find_for(path: path, **service_params)
|
2021-04-17 20:07:23 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def service_params
|
|
|
|
{
|
|
|
|
project: environment.project,
|
|
|
|
user: current_user,
|
|
|
|
options: { environment: environment }
|
|
|
|
}
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|