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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
4d8f3978
Commit
4d8f3978
authored
May 25, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use before action to respond with 404 if prometheus metrics are missing
parent
61d7b7f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
app/controllers/projects/prometheus_controller.rb
app/controllers/projects/prometheus_controller.rb
+7
-1
No files found.
app/controllers/projects/prometheus_controller.rb
View file @
4d8f3978
class
Projects::PrometheusController
<
Projects
::
ApplicationController
before_action
:authorize_read_project!
before_action
:require_prometheus_metrics!
def
active_metrics
return
render_404
unless
has_prometheus_metrics?
matched_metrics
=
prometheus_service
.
reactive_query
(
Gitlab
::
Prometheus
::
Queries
::
MatchedMetricsQuery
.
name
,
&
:itself
)
if
matched_metrics
...
...
@@ -12,6 +12,8 @@ class Projects::PrometheusController < Projects::ApplicationController
end
end
private
def
prometheus_service
project
.
monitoring_service
end
...
...
@@ -19,4 +21,8 @@ class Projects::PrometheusController < Projects::ApplicationController
def
has_prometheus_metrics?
prometheus_service
&
.
respond_to?
(
:reactive_query
)
end
def
require_prometheus_metrics!
render_404
unless
has_prometheus_metrics?
end
end
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