BigW Consortium Gitlab

Commit 4d8f3978 by Pawel Chojnacki

Use before action to respond with 404 if prometheus metrics are missing

parent 61d7b7f1
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment