debian-mirror-gitlab/app/models/performance_monitoring/prometheus_panel.rb

29 lines
732 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module PerformanceMonitoring
class PrometheusPanel
include ActiveModel::Model
2020-04-22 19:07:51 +05:30
attr_accessor :type, :title, :y_label, :weight, :metrics, :y_axis, :max_value
2020-03-13 15:44:24 +05:30
validates :title, presence: true
validates :metrics, presence: true
def self.from_json(json_content)
panel = new(
type: json_content['type'],
title: json_content['title'],
y_label: json_content['y_label'],
weight: json_content['weight'],
metrics: json_content['metrics'].map { |metric| PrometheusMetric.from_json(metric) }
)
panel.tap(&:validate!)
end
2020-04-22 19:07:51 +05:30
def id(group_title)
Digest::SHA2.hexdigest([group_title, type, title].join)
end
2020-03-13 15:44:24 +05:30
end
end