Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7e027db6
Commit
7e027db6
authored
Jul 28, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move PrometheusMetricEnums to Enums::PrometheusMetric
Move enums related modules to a separate directory
parent
40a314b8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
92 deletions
+94
-92
app/models/concerns/enums/prometheus_metric.rb
app/models/concerns/enums/prometheus_metric.rb
+86
-0
app/models/prometheus_metric.rb
app/models/prometheus_metric.rb
+2
-2
app/models/prometheus_metric_enums.rb
app/models/prometheus_metric_enums.rb
+0
-84
app/services/metrics/dashboard/custom_metric_embed_service.rb
...services/metrics/dashboard/custom_metric_embed_service.rb
+3
-3
lib/gitlab/metrics/dashboard/stages/custom_metrics_details_inserter.rb
...trics/dashboard/stages/custom_metrics_details_inserter.rb
+1
-1
spec/lib/gitlab/database_importers/common_metrics/prometheus_metric_spec.rb
...tabase_importers/common_metrics/prometheus_metric_spec.rb
+1
-1
spec/support/helpers/metrics_dashboard_helpers.rb
spec/support/helpers/metrics_dashboard_helpers.rb
+1
-1
No files found.
app/models/concerns/enums/prometheus_metric.rb
0 → 100644
View file @
7e027db6
# frozen_string_literal: true
module
Enums
module
PrometheusMetric
def
self
.
groups
{
# built-in groups
nginx_ingress_vts:
-
1
,
ha_proxy:
-
2
,
aws_elb:
-
3
,
nginx:
-
4
,
kubernetes:
-
5
,
nginx_ingress:
-
6
,
cluster_health:
-
100
}.
merge
(
custom_groups
).
freeze
end
# custom/user groups
def
self
.
custom_groups
{
business:
0
,
response:
1
,
system:
2
}.
freeze
end
def
self
.
group_details
{
# built-in groups
nginx_ingress_vts:
{
group_title:
_
(
'Response metrics (NGINX Ingress VTS)'
),
required_metrics:
%w(nginx_upstream_responses_total nginx_upstream_response_msecs_avg)
,
priority:
10
}.
freeze
,
nginx_ingress:
{
group_title:
_
(
'Response metrics (NGINX Ingress)'
),
required_metrics:
%w(nginx_ingress_controller_requests nginx_ingress_controller_ingress_upstream_latency_seconds_sum)
,
priority:
10
}.
freeze
,
ha_proxy:
{
group_title:
_
(
'Response metrics (HA Proxy)'
),
required_metrics:
%w(haproxy_frontend_http_requests_total haproxy_frontend_http_responses_total)
,
priority:
10
}.
freeze
,
aws_elb:
{
group_title:
_
(
'Response metrics (AWS ELB)'
),
required_metrics:
%w(aws_elb_request_count_sum aws_elb_latency_average aws_elb_httpcode_backend_5_xx_sum)
,
priority:
10
}.
freeze
,
nginx:
{
group_title:
_
(
'Response metrics (NGINX)'
),
required_metrics:
%w(nginx_server_requests nginx_server_requestMsec)
,
priority:
10
}.
freeze
,
kubernetes:
{
group_title:
_
(
'System metrics (Kubernetes)'
),
required_metrics:
%w(container_memory_usage_bytes container_cpu_usage_seconds_total)
,
priority:
5
}.
freeze
,
cluster_health:
{
group_title:
_
(
'Cluster Health'
),
required_metrics:
%w(container_memory_usage_bytes container_cpu_usage_seconds_total)
,
priority:
10
}.
freeze
}.
merge
(
custom_group_details
).
freeze
end
# 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
}.
freeze
,
system:
{
group_title:
_
(
'System metrics (Custom)'
),
priority:
-
10
}.
freeze
}.
freeze
end
end
end
app/models/prometheus_metric.rb
View file @
7e027db6
...
...
@@ -4,7 +4,7 @@ class PrometheusMetric < ApplicationRecord
belongs_to
:project
,
validate:
true
,
inverse_of: :prometheus_metrics
has_many
:prometheus_alerts
,
inverse_of: :prometheus_metric
enum
group:
PrometheusMetricEnums
.
groups
enum
group:
Enums
::
PrometheusMetric
.
groups
validates
:title
,
presence:
true
validates
:query
,
presence:
true
...
...
@@ -72,6 +72,6 @@ class PrometheusMetric < ApplicationRecord
private
def
group_details
(
group
)
PrometheusMetricEnums
.
group_details
.
fetch
(
group
.
to_sym
)
Enums
::
PrometheusMetric
.
group_details
.
fetch
(
group
.
to_sym
)
end
end
app/models/prometheus_metric_enums.rb
deleted
100644 → 0
View file @
40a314b8
# frozen_string_literal: true
module
PrometheusMetricEnums
def
self
.
groups
{
# built-in groups
nginx_ingress_vts:
-
1
,
ha_proxy:
-
2
,
aws_elb:
-
3
,
nginx:
-
4
,
kubernetes:
-
5
,
nginx_ingress:
-
6
,
cluster_health:
-
100
}.
merge
(
custom_groups
).
freeze
end
# custom/user groups
def
self
.
custom_groups
{
business:
0
,
response:
1
,
system:
2
}.
freeze
end
def
self
.
group_details
{
# built-in groups
nginx_ingress_vts:
{
group_title:
_
(
'Response metrics (NGINX Ingress VTS)'
),
required_metrics:
%w(nginx_upstream_responses_total nginx_upstream_response_msecs_avg)
,
priority:
10
}.
freeze
,
nginx_ingress:
{
group_title:
_
(
'Response metrics (NGINX Ingress)'
),
required_metrics:
%w(nginx_ingress_controller_requests nginx_ingress_controller_ingress_upstream_latency_seconds_sum)
,
priority:
10
}.
freeze
,
ha_proxy:
{
group_title:
_
(
'Response metrics (HA Proxy)'
),
required_metrics:
%w(haproxy_frontend_http_requests_total haproxy_frontend_http_responses_total)
,
priority:
10
}.
freeze
,
aws_elb:
{
group_title:
_
(
'Response metrics (AWS ELB)'
),
required_metrics:
%w(aws_elb_request_count_sum aws_elb_latency_average aws_elb_httpcode_backend_5_xx_sum)
,
priority:
10
}.
freeze
,
nginx:
{
group_title:
_
(
'Response metrics (NGINX)'
),
required_metrics:
%w(nginx_server_requests nginx_server_requestMsec)
,
priority:
10
}.
freeze
,
kubernetes:
{
group_title:
_
(
'System metrics (Kubernetes)'
),
required_metrics:
%w(container_memory_usage_bytes container_cpu_usage_seconds_total)
,
priority:
5
}.
freeze
,
cluster_health:
{
group_title:
_
(
'Cluster Health'
),
required_metrics:
%w(container_memory_usage_bytes container_cpu_usage_seconds_total)
,
priority:
10
}.
freeze
}.
merge
(
custom_group_details
).
freeze
end
# 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
}.
freeze
,
system:
{
group_title:
_
(
'System metrics (Custom)'
),
priority:
-
10
}.
freeze
}.
freeze
end
end
app/services/metrics/dashboard/custom_metric_embed_service.rb
View file @
7e027db6
...
...
@@ -31,7 +31,7 @@ module Metrics
# A group title is valid if it is one of the limited
# options the user can select in the UI.
def
valid_group_title?
(
group
)
PrometheusMetricEnums
Enums
::
PrometheusMetric
.
custom_group_details
.
map
{
|
_
,
details
|
details
[
:group_title
]
}
.
include?
(
group
)
...
...
@@ -99,12 +99,12 @@ module Metrics
# Returns a symbol representing the group that
# the dashboard's group title belongs to.
# It will be one of the keys found under
#
PrometheusMetricEnums
.custom_groups.
#
Enums::PrometheusMetric
.custom_groups.
#
# @return [String]
def
group_key
strong_memoize
(
:group_key
)
do
PrometheusMetricEnums
Enums
::
PrometheusMetric
.
group_details
.
find
{
|
_
,
details
|
details
[
:group_title
]
==
group
}
.
first
...
...
lib/gitlab/metrics/dashboard/stages/custom_metrics_details_inserter.rb
View file @
7e027db6
...
...
@@ -27,7 +27,7 @@ module Gitlab
private
def
custom_group_titles
@custom_group_titles
||=
PrometheusMetricEnums
.
custom_group_details
.
values
.
map
{
|
group_details
|
group_details
[
:group_title
]
}
@custom_group_titles
||=
Enums
::
PrometheusMetric
.
custom_group_details
.
values
.
map
{
|
group_details
|
group_details
[
:group_title
]
}
end
def
edit_path
(
metric
)
...
...
spec/lib/gitlab/database_importers/common_metrics/prometheus_metric_spec.rb
View file @
7e027db6
...
...
@@ -8,7 +8,7 @@ RSpec.describe Gitlab::DatabaseImporters::CommonMetrics::PrometheusMetric do
end
it
'.group_titles equals ::PrometheusMetric'
do
existing_group_titles
=
::
PrometheusMetricEnums
.
group_details
.
transform_values
do
|
value
|
existing_group_titles
=
Enums
::
PrometheusMetric
.
group_details
.
transform_values
do
|
value
|
value
[
:group_title
]
end
expect
(
Gitlab
::
DatabaseImporters
::
CommonMetrics
::
PrometheusMetricEnums
.
group_titles
).
to
eq
(
existing_group_titles
)
...
...
spec/support/helpers/metrics_dashboard_helpers.rb
View file @
7e027db6
...
...
@@ -47,7 +47,7 @@ module MetricsDashboardHelpers
end
def
business_metric_title
PrometheusMetricEnums
.
group_details
[
:business
][
:group_title
]
Enums
::
PrometheusMetric
.
group_details
[
:business
][
:group_title
]
end
def
self_monitoring_dashboard_path
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment