debian-mirror-gitlab/app/controllers/metrics_controller.rb
2019-02-13 22:33:31 +05:30

26 lines
791 B
Ruby

# frozen_string_literal: true
class MetricsController < ActionController::Base
include RequiresWhitelistedMonitoringClient
protect_from_forgery with: :exception, prepend: true
def index
response = if Gitlab::Metrics.prometheus_metrics_enabled?
metrics_service.metrics_text
else
help_page = help_page_url('administration/monitoring/prometheus/gitlab_metrics',
anchor: 'gitlab-prometheus-metrics'
)
"# Metrics are disabled, see: #{help_page}\n"
end
render plain: response, content_type: 'text/plain; version=0.0.4'
end
private
def metrics_service
@metrics_service ||= MetricsService.new
end
end