Commit aaeda829 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Add Y Label field to yml and responses

parent c24d20da
......@@ -2,6 +2,7 @@
priority: 1
metrics:
- title: "Memory usage"
y_label: "Values"
detect: container_memory_usage_bytes
weight: 1
queries:
......
module Gitlab::Prometheus
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
@title = title
@detect = detect
@weight = weight
@y_label = y_label || 'Values'
@queries = queries
end
......@@ -14,7 +15,7 @@ module Gitlab::Prometheus
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?
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
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
{
title: metric.title,
weight: metric.weight,
y_label: metric.y_label,
queries: metric.queries.map(&query_processor)
}
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