BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
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
class
Projects
::
PrometheusController
<
Projects
::
ApplicationController
before_action
:authorize_read_project!
before_action
:authorize_read_project!
before_action
:require_prometheus_metrics!
def
active_metrics
def
active_metrics
return
render_404
unless
has_prometheus_metrics?
matched_metrics
=
prometheus_service
.
reactive_query
(
Gitlab
::
Prometheus
::
Queries
::
MatchedMetricsQuery
.
name
,
&
:itself
)
matched_metrics
=
prometheus_service
.
reactive_query
(
Gitlab
::
Prometheus
::
Queries
::
MatchedMetricsQuery
.
name
,
&
:itself
)
if
matched_metrics
if
matched_metrics
...
@@ -12,6 +12,8 @@ class Projects::PrometheusController < Projects::ApplicationController
...
@@ -12,6 +12,8 @@ class Projects::PrometheusController < Projects::ApplicationController
end
end
end
end
private
def
prometheus_service
def
prometheus_service
project
.
monitoring_service
project
.
monitoring_service
end
end
...
@@ -19,4 +21,8 @@ class Projects::PrometheusController < Projects::ApplicationController
...
@@ -19,4 +21,8 @@ class Projects::PrometheusController < Projects::ApplicationController
def
has_prometheus_metrics?
def
has_prometheus_metrics?
prometheus_service
&
.
respond_to?
(
:reactive_query
)
prometheus_service
&
.
respond_to?
(
:reactive_query
)
end
end
def
require_prometheus_metrics!
render_404
unless
has_prometheus_metrics?
end
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