gitlab-org--gitlab-foss/lib/gitlab/prometheus/metric_group.rb
Kamil Trzciński 0a9d771bcb Import common metrics into database.
This MR backports PrometheusMetric model to CE
and adds: common, identifier to figure out what kind of metric is used.
2018-09-04 12:19:22 +02:00

22 lines
521 B
Ruby

module Gitlab
module Prometheus
class MetricGroup
include ActiveModel::Model
attr_accessor :name, :priority, :metrics
validates :name, :priority, :metrics, presence: true
def self.common_metrics
::PrometheusMetric.common.group_by(&:group_title).map do |name, metrics|
MetricGroup.new(name: name, priority: 0, metrics: metrics.map(&:to_query_metric))
end
end
# EE only
def self.for_project(_)
common_metrics
end
end
end
end