Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/prometheus_controller.rb')
-rw-r--r--app/controllers/projects/prometheus_controller.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/projects/prometheus_controller.rb b/app/controllers/projects/prometheus_controller.rb
index 0402be6f85c..4a39d13881e 100644
--- a/app/controllers/projects/prometheus_controller.rb
+++ b/app/controllers/projects/prometheus_controller.rb
@@ -3,17 +3,25 @@ class Projects::PrometheusController < Projects::ApplicationController
before_action :require_prometheus_metrics!
def active_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
- render json: matched_metrics, status: :ok
- else
- head :no_content
+ respond_to do |format|
+ format.json do
+ if matched_metrics.any?
+ render json: matched_metrics
+ else
+ head :no_content
+ end
+ end
end
end
private
+ rescue_from(ActionController::UnknownFormat) do |e|
+ render_404
+ end
+
def prometheus_service
project.monitoring_service
end