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
e8163573
Commit
e8163573
authored
May 15, 2020
by
Stan Hu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rc/fix_logs_path' into 'master'
Fix missing logs_path See merge request gitlab-org/gitlab!30805
parents
d3ec621d
859e7996
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
36 deletions
+81
-36
app/controllers/concerns/metrics_dashboard.rb
app/controllers/concerns/metrics_dashboard.rb
+1
-1
app/helpers/environments_helper.rb
app/helpers/environments_helper.rb
+61
-27
ee/app/helpers/ee/environments_helper.rb
ee/app/helpers/ee/environments_helper.rb
+13
-3
ee/spec/support/shared_examples/controllers/cluster_metrics_shared_examples.rb
...d_examples/controllers/cluster_metrics_shared_examples.rb
+1
-1
spec/controllers/concerns/metrics_dashboard_spec.rb
spec/controllers/concerns/metrics_dashboard_spec.rb
+2
-2
spec/controllers/projects/grafana_api_controller_spec.rb
spec/controllers/projects/grafana_api_controller_spec.rb
+2
-1
spec/controllers/projects/prometheus/alerts_controller_spec.rb
...controllers/projects/prometheus/alerts_controller_spec.rb
+1
-1
No files found.
app/controllers/concerns/metrics_dashboard.rb
View file @
e8163573
...
...
@@ -18,7 +18,7 @@ module MetricsDashboard
if
result
result
[
:all_dashboards
]
=
all_dashboards
if
include_all_dashboards?
result
[
:metrics_data
]
=
metrics_data
(
project_for_dashboard
,
environment_for_dashboard
)
if
project_for_dashboard
&&
environment_for_dashboard
result
[
:metrics_data
]
=
metrics_data
(
project_for_dashboard
,
environment_for_dashboard
)
end
respond_to
do
|
format
|
...
...
app/helpers/environments_helper.rb
View file @
e8163573
...
...
@@ -22,33 +22,13 @@ module EnvironmentsHelper
end
def
metrics_data
(
project
,
environment
)
{
"settings-path"
=>
edit_project_service_path
(
project
,
'prometheus'
),
"clusters-path"
=>
project_clusters_path
(
project
),
"current-environment-name"
=>
environment
.
name
,
"documentation-path"
=>
help_page_path
(
'administration/monitoring/prometheus/index.md'
),
"empty-getting-started-svg-path"
=>
image_path
(
'illustrations/monitoring/getting_started.svg'
),
"empty-loading-svg-path"
=>
image_path
(
'illustrations/monitoring/loading.svg'
),
"empty-no-data-svg-path"
=>
image_path
(
'illustrations/monitoring/no_data.svg'
),
"empty-no-data-small-svg-path"
=>
image_path
(
'illustrations/chart-empty-state-small.svg'
),
"empty-unable-to-connect-svg-path"
=>
image_path
(
'illustrations/monitoring/unable_to_connect.svg'
),
"metrics-endpoint"
=>
additional_metrics_project_environment_path
(
project
,
environment
,
format: :json
),
"dashboards-endpoint"
=>
project_performance_monitoring_dashboards_path
(
project
,
format: :json
),
"dashboard-endpoint"
=>
metrics_dashboard_project_environment_path
(
project
,
environment
,
format: :json
),
"deployments-endpoint"
=>
project_environment_deployments_path
(
project
,
environment
,
format: :json
),
"default-branch"
=>
project
.
default_branch
,
"project-path"
=>
project_path
(
project
),
"tags-path"
=>
project_tags_path
(
project
),
"has-metrics"
=>
"
#{
environment
.
has_metrics?
}
"
,
"prometheus-status"
=>
"
#{
environment
.
prometheus_status
}
"
,
"external-dashboard-url"
=>
project
.
metrics_setting_external_dashboard_url
,
"environment-state"
=>
"
#{
environment
.
state
}
"
,
"custom-metrics-path"
=>
project_prometheus_metrics_path
(
project
),
"validate-query-path"
=>
validate_query_project_prometheus_metrics_path
(
project
),
"custom-metrics-available"
=>
"
#{
custom_metrics_available?
(
project
)
}
"
,
"alerts-endpoint"
=>
project_prometheus_alerts_path
(
project
,
environment_id:
environment
.
id
,
format: :json
),
"prometheus-alerts-available"
=>
"
#{
can?
(
current_user
,
:read_prometheus_alerts
,
project
)
}
"
}
metrics_data
=
{}
metrics_data
.
merge!
(
project_metrics_data
(
project
))
if
project
metrics_data
.
merge!
(
environment_metrics_data
(
environment
))
if
environment
metrics_data
.
merge!
(
project_and_environment_metrics_data
(
project
,
environment
))
if
project
&&
environment
metrics_data
.
merge!
(
static_metrics_data
)
metrics_data
end
def
environment_logs_data
(
project
,
environment
)
...
...
@@ -63,6 +43,60 @@ module EnvironmentsHelper
def
can_destroy_environment?
(
environment
)
can?
(
current_user
,
:destroy_environment
,
environment
)
end
private
def
project_metrics_data
(
project
)
return
{}
unless
project
{
'settings-path'
=>
edit_project_service_path
(
project
,
'prometheus'
),
'clusters-path'
=>
project_clusters_path
(
project
),
'dashboards-endpoint'
=>
project_performance_monitoring_dashboards_path
(
project
,
format: :json
),
'default-branch'
=>
project
.
default_branch
,
'project-path'
=>
project_path
(
project
),
'tags-path'
=>
project_tags_path
(
project
),
'external-dashboard-url'
=>
project
.
metrics_setting_external_dashboard_url
,
'custom-metrics-path'
=>
project_prometheus_metrics_path
(
project
),
'validate-query-path'
=>
validate_query_project_prometheus_metrics_path
(
project
),
'custom-metrics-available'
=>
"
#{
custom_metrics_available?
(
project
)
}
"
,
'prometheus-alerts-available'
=>
"
#{
can?
(
current_user
,
:read_prometheus_alerts
,
project
)
}
"
}
end
def
environment_metrics_data
(
environment
)
return
{}
unless
environment
{
'current-environment-name'
=>
environment
.
name
,
'has-metrics'
=>
"
#{
environment
.
has_metrics?
}
"
,
'prometheus-status'
=>
"
#{
environment
.
prometheus_status
}
"
,
'environment-state'
=>
"
#{
environment
.
state
}
"
}
end
def
project_and_environment_metrics_data
(
project
,
environment
)
return
{}
unless
project
&&
environment
{
'metrics-endpoint'
=>
additional_metrics_project_environment_path
(
project
,
environment
,
format: :json
),
'dashboard-endpoint'
=>
metrics_dashboard_project_environment_path
(
project
,
environment
,
format: :json
),
'deployments-endpoint'
=>
project_environment_deployments_path
(
project
,
environment
,
format: :json
),
'alerts-endpoint'
=>
project_prometheus_alerts_path
(
project
,
environment_id:
environment
.
id
,
format: :json
)
}
end
def
static_metrics_data
{
'documentation-path'
=>
help_page_path
(
'administration/monitoring/prometheus/index.md'
),
'empty-getting-started-svg-path'
=>
image_path
(
'illustrations/monitoring/getting_started.svg'
),
'empty-loading-svg-path'
=>
image_path
(
'illustrations/monitoring/loading.svg'
),
'empty-no-data-svg-path'
=>
image_path
(
'illustrations/monitoring/no_data.svg'
),
'empty-no-data-small-svg-path'
=>
image_path
(
'illustrations/chart-empty-state-small.svg'
),
'empty-unable-to-connect-svg-path'
=>
image_path
(
'illustrations/monitoring/unable_to_connect.svg'
)
}
end
end
EnvironmentsHelper
.
prepend_if_ee
(
'::EE::EnvironmentsHelper'
)
ee/app/helpers/ee/environments_helper.rb
View file @
e8163573
...
...
@@ -30,10 +30,20 @@ module EE
super
.
merge
(
ee_environments_folder_list_view_data
)
end
override
:metrics_data
def
metrics_data
(
project
,
environmen
t
)
override
:
project_
metrics_data
def
project_metrics_data
(
projec
t
)
ee_metrics_data
=
{}
ee_metrics_data
[
"logs_path"
]
=
project_logs_path
(
project
,
environment_name:
environment
.
name
)
if
can?
(
current_user
,
:read_pod_logs
,
project
)
ee_metrics_data
[
'logs_path'
]
=
project_logs_path
(
project
)
if
can?
(
current_user
,
:read_pod_logs
,
project
)
super
.
merge
(
ee_metrics_data
)
end
override
:project_and_environment_metrics_data
def
project_and_environment_metrics_data
(
project
,
environment
)
ee_metrics_data
=
{}
# overwrites project_metrics_data logs_path if environment is available
ee_metrics_data
[
'logs_path'
]
=
project_logs_path
(
project
,
environment_name:
environment
.
name
)
if
can?
(
current_user
,
:read_pod_logs
,
project
)
super
.
merge
(
ee_metrics_data
)
end
...
...
ee/spec/support/shared_examples/controllers/cluster_metrics_shared_examples.rb
View file @
e8163573
...
...
@@ -191,7 +191,7 @@ RSpec.shared_examples 'cluster metrics' do
get
:metrics_dashboard
,
params:
metrics_params
,
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
keys
).
to
contain_exactly
(
'dashboard'
,
'status'
)
expect
(
json_response
.
keys
).
to
contain_exactly
(
'dashboard'
,
'status'
,
'metrics_data'
)
end
it
'is the default dashboard'
do
...
...
spec/controllers/concerns/metrics_dashboard_spec.rb
View file @
e8163573
...
...
@@ -45,7 +45,7 @@ describe MetricsDashboard do
it
'returns the specified dashboard'
do
expect
(
json_response
[
'dashboard'
][
'dashboard'
]).
to
eq
(
'Environment metrics'
)
expect
(
json_response
).
not_to
have_key
(
'all_dashboards'
)
expect
(
json_response
).
not_
to
have_key
(
'metrics_data'
)
expect
(
json_response
).
to
have_key
(
'metrics_data'
)
end
context
'when the params are in an alternate format'
do
...
...
@@ -54,7 +54,7 @@ describe MetricsDashboard do
it
'returns the specified dashboard'
do
expect
(
json_response
[
'dashboard'
][
'dashboard'
]).
to
eq
(
'Environment metrics'
)
expect
(
json_response
).
not_to
have_key
(
'all_dashboards'
)
expect
(
json_response
).
not_
to
have_key
(
'metrics_data'
)
expect
(
json_response
).
to
have_key
(
'metrics_data'
)
end
end
...
...
spec/controllers/projects/grafana_api_controller_spec.rb
View file @
e8163573
...
...
@@ -131,10 +131,11 @@ describe Projects::GrafanaApiController do
get
:metrics_dashboard
,
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
eq
({
expect
(
json_response
).
to
include
({
'dashboard'
=>
'{}'
,
'status'
=>
'success'
})
expect
(
json_response
).
to
include
(
'metrics_data'
)
end
end
...
...
spec/controllers/projects/prometheus/alerts_controller_spec.rb
View file @
e8163573
...
...
@@ -352,7 +352,7 @@ describe Projects::Prometheus::AlertsController do
get
:metrics_dashboard
,
params:
request_params
(
id:
metric
.
id
,
environment_id:
alert
.
environment
.
id
),
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
keys
).
to
contain_exactly
(
'dashboard'
,
'status'
)
expect
(
json_response
.
keys
).
to
contain_exactly
(
'dashboard'
,
'status'
,
'metrics_data'
)
end
it
'is the correct embed'
do
...
...
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