2019-07-29 23:03:59 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Fetches the system metrics dashboard and formats the output.
|
|
|
|
# Use Gitlab::Metrics::Dashboard::Finder to retrive dashboards.
|
|
|
|
module Metrics
|
|
|
|
module Dashboard
|
|
|
|
class SystemDashboardService < ::Metrics::Dashboard::BaseService
|
|
|
|
SYSTEM_DASHBOARD_PATH = 'config/prometheus/common_metrics.yml'
|
|
|
|
SYSTEM_DASHBOARD_NAME = 'Default'
|
|
|
|
|
2019-09-18 14:02:45 +00:00
|
|
|
SEQUENCE = [
|
|
|
|
STAGES::CommonMetricsInserter,
|
|
|
|
STAGES::ProjectMetricsInserter,
|
|
|
|
STAGES::EndpointInserter,
|
|
|
|
STAGES::Sorter
|
|
|
|
].freeze
|
|
|
|
|
2019-07-29 23:03:59 +00:00
|
|
|
class << self
|
|
|
|
def all_dashboard_paths(_project)
|
|
|
|
[{
|
|
|
|
path: SYSTEM_DASHBOARD_PATH,
|
|
|
|
display_name: SYSTEM_DASHBOARD_NAME,
|
|
|
|
default: true
|
|
|
|
}]
|
|
|
|
end
|
|
|
|
|
|
|
|
def system_dashboard?(filepath)
|
|
|
|
filepath == SYSTEM_DASHBOARD_PATH
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-09-18 14:02:45 +00:00
|
|
|
def cache_key
|
|
|
|
"metrics_dashboard_#{dashboard_path}"
|
|
|
|
end
|
|
|
|
|
2019-07-29 23:03:59 +00:00
|
|
|
def dashboard_path
|
|
|
|
SYSTEM_DASHBOARD_PATH
|
|
|
|
end
|
|
|
|
|
|
|
|
# Returns the base metrics shipped with every GitLab service.
|
|
|
|
def get_raw_dashboard
|
|
|
|
yml = File.read(Rails.root.join(dashboard_path))
|
|
|
|
|
|
|
|
YAML.safe_load(yml)
|
|
|
|
end
|
|
|
|
|
2019-09-18 14:02:45 +00:00
|
|
|
def sequence
|
|
|
|
SEQUENCE
|
2019-07-29 23:03:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-09-18 14:02:45 +00:00
|
|
|
|
|
|
|
Metrics::Dashboard::SystemDashboardService.prepend_if_ee('EE::Metrics::Dashboard::SystemDashboardService')
|