Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarah Yasonik <syasonik@gitlab.com>2019-08-07 19:17:35 +0300
committerSean McGivern <sean@gitlab.com>2019-08-07 19:17:35 +0300
commitbf918b68f643266e91a9308cbc64a8304c647f17 (patch)
treeddface6092de44fafe2e0929158fc65d92766f47 /app/models
parentd8966abd20c860d2f30141f3647f2b81f70b683d (diff)
Support dashboard params for metrics dashboard
https://gitlab.com/gitlab-org/gitlab-ce/issues/62971 Adds support to EnvironmentsController#metrics_dashboard for the following params: group, title, y_label These params are used to uniquely identify a panel on the metrics dashboard. Metrics are stored in several places, so this adds utilities to find a specific panel from the database or filesystem depending on the metric specified. Also moves some shared utilities into separate classes, notably default values and errors.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/prometheus_metric.rb4
-rw-r--r--app/models/prometheus_metric_enums.rb20
2 files changed, 18 insertions, 6 deletions
diff --git a/app/models/prometheus_metric.rb b/app/models/prometheus_metric.rb
index b8e7673dcf5..c7786500c5c 100644
--- a/app/models/prometheus_metric.rb
+++ b/app/models/prometheus_metric.rb
@@ -32,6 +32,10 @@ class PrometheusMetric < ApplicationRecord
Gitlab::Prometheus::Metric.new(id: id, title: title, required_metrics: required_metrics, weight: 0, y_label: y_label, queries: queries)
end
+ def to_metric_hash
+ queries.first.merge(metric_id: id)
+ end
+
def queries
[
{
diff --git a/app/models/prometheus_metric_enums.rb b/app/models/prometheus_metric_enums.rb
index 6cb22cc69cd..d58f825f222 100644
--- a/app/models/prometheus_metric_enums.rb
+++ b/app/models/prometheus_metric_enums.rb
@@ -9,13 +9,17 @@ module PrometheusMetricEnums
aws_elb: -3,
nginx: -4,
kubernetes: -5,
- nginx_ingress: -6,
+ nginx_ingress: -6
+ }.merge(custom_groups).freeze
+ end
- # custom/user groups
+ # custom/user groups
+ def self.custom_groups
+ {
business: 0,
response: 1,
system: 2
- }
+ }.freeze
end
def self.group_details
@@ -50,16 +54,20 @@ module PrometheusMetricEnums
group_title: _('System metrics (Kubernetes)'),
required_metrics: %w(container_memory_usage_bytes container_cpu_usage_seconds_total),
priority: 5
- }.freeze,
+ }.freeze
+ }.merge(custom_group_details).freeze
+ end
- # custom/user groups
+ # custom/user groups
+ def self.custom_group_details
+ {
business: {
group_title: _('Business metrics (Custom)'),
priority: 0
}.freeze,
response: {
group_title: _('Response metrics (Custom)'),
- priority: -5
+ priority: -5
}.freeze,
system: {
group_title: _('System metrics (Custom)'),