2018-11-19 21:01:13 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-06 10:07:33 -04:00
|
|
|
module Gitlab
|
|
|
|
module Prometheus
|
|
|
|
class MetricGroup
|
2017-06-16 08:23:33 -04:00
|
|
|
include ActiveModel::Model
|
2017-05-10 05:25:30 -04:00
|
|
|
|
2017-06-16 08:23:33 -04:00
|
|
|
attr_accessor :name, :priority, :metrics
|
2018-08-31 12:53:50 -04:00
|
|
|
|
2017-06-16 08:23:33 -04:00
|
|
|
validates :name, :priority, :metrics, presence: true
|
2017-05-10 05:25:30 -04:00
|
|
|
|
2018-02-23 12:58:40 -05:00
|
|
|
def self.common_metrics
|
2018-12-21 06:11:58 -05:00
|
|
|
all_groups = ::PrometheusMetric.common.group_by(&:group_title).map do |name, metrics|
|
|
|
|
MetricGroup.new(
|
|
|
|
name: name,
|
|
|
|
priority: metrics.map(&:priority).max,
|
|
|
|
metrics: metrics.map(&:to_query_metric)
|
|
|
|
)
|
2018-08-31 12:53:50 -04:00
|
|
|
end
|
2018-12-21 06:11:58 -05:00
|
|
|
|
|
|
|
all_groups.sort_by(&:priority).reverse
|
2017-06-06 10:07:33 -04:00
|
|
|
end
|
2018-02-23 12:58:40 -05:00
|
|
|
|
|
|
|
# EE only
|
|
|
|
def self.for_project(_)
|
|
|
|
common_metrics
|
|
|
|
end
|
2017-05-10 05:25:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|