BigW Consortium Gitlab

metrics_controller.rb 470 Bytes
Newer Older
1
class MetricsController < ActionController::Base
2 3
  include RequiresHealthToken

4
  protect_from_forgery with: :exception
5

6
  before_action :validate_prometheus_metrics
7

8 9
  def index
    render text: metrics_service.metrics_text, content_type: 'text/plain; verssion=0.0.4'
10 11 12 13
  end

  private

14 15
  def metrics_service
    @metrics_service ||= MetricsService.new
16 17
  end

18 19
  def validate_prometheus_metrics
    render_404 unless Gitlab::Metrics.prometheus_metrics_enabled?
20 21
  end
end