BigW Consortium Gitlab

prometheus_controller.rb 564 Bytes
Newer Older
1 2
class Projects::PrometheusController < Projects::ApplicationController
  before_action :authorize_read_project!
3
  before_action :require_prometheus_metrics!
4 5

  def active_metrics
6 7
    respond_to do |format|
      format.json do
8
        matched_metrics = project.prometheus_service.matched_metrics || {}
9

10 11 12 13 14 15
        if matched_metrics.any?
          render json: matched_metrics
        else
          head :no_content
        end
      end
16 17 18
    end
  end

19 20 21
  private

  def require_prometheus_metrics!
22
    render_404 unless project.prometheus_service.present?
23
  end
24
end