summaryrefslogtreecommitdiff
path: root/lib/gitlab/metrics/dashboard/system_dashboard_service.rb
blob: 67509ed4230ff1ec79b20e80c51701be6d39b29f (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
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

# Fetches the system metrics dashboard and formats the output.
# Use Gitlab::Metrics::Dashboard::Finder to retrive dashboards.
module Gitlab
  module Metrics
    module Dashboard
      class SystemDashboardService < Gitlab::Metrics::Dashboard::BaseService
        SYSTEM_DASHBOARD_PATH = 'config/prometheus/common_metrics.yml'

        class << self
          def all_dashboard_paths(_project)
            [{
              path: SYSTEM_DASHBOARD_PATH,
              default: true
            }]
          end

          def system_dashboard?(filepath)
            filepath == SYSTEM_DASHBOARD_PATH
          end
        end

        private

        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

        def cache_key
          "metrics_dashboard_#{dashboard_path}"
        end

        def insert_project_metrics?
          true
        end
      end
    end
  end
end