Commit aaeda829 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Add Y Label field to yml and responses

parent c24d20da
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
priority: 1 priority: 1
metrics: metrics:
- title: "Memory usage" - title: "Memory usage"
y_label: "Values"
detect: container_memory_usage_bytes detect: container_memory_usage_bytes
weight: 1 weight: 1
queries: queries:
......
module Gitlab::Prometheus module Gitlab::Prometheus
class Metric class Metric
attr_reader :group, :title, :detect, :weight, :queries attr_reader :group, :title, :detect, :weight, :y_label, :queries
def initialize(group, title, detect, weight, queries = []) def initialize(group, title, detect, weight, y_label, queries = [])
@group = group @group = group
@title = title @title = title
@detect = detect @detect = detect
@weight = weight @weight = weight
@y_label = y_label || 'Values'
@queries = queries @queries = queries
end end
...@@ -14,7 +15,7 @@ module Gitlab::Prometheus ...@@ -14,7 +15,7 @@ module Gitlab::Prometheus
missing_fields = [:title, :detect, :weight, :queries].select { |key| !entry.has_key?(key) } missing_fields = [:title, :detect, :weight, :queries].select { |key| !entry.has_key?(key) }
raise ParsingError.new("entry missing required fields #{missing_fields}") unless missing_fields.empty? raise ParsingError.new("entry missing required fields #{missing_fields}") unless missing_fields.empty?
Metric.new(group, entry[:title], entry[:detect], entry[:weight], entry[:queries]) Metric.new(group, entry[:title], entry[:detect], entry[:weight], entry[:y_label],entry[:queries])
end end
def self.metrics_from_list(group, list) def self.metrics_from_list(group, list)
......
module Gitlab::Prometheus
module MetricsSources
def self.additional_metrics
@additional_metrics ||= YAML.load_file(Rails.root.join('config/additional_metrics.yml')).deep_symbolize_keys.freeze
end
end
end
...@@ -22,6 +22,7 @@ module Gitlab::Prometheus::Queries ...@@ -22,6 +22,7 @@ module Gitlab::Prometheus::Queries
{ {
title: metric.title, title: metric.title,
weight: metric.weight, weight: metric.weight,
y_label: metric.y_label,
queries: metric.queries.map(&query_processor) queries: metric.queries.map(&query_processor)
} }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment