2017-05-19 11:03:10 -04:00
|
|
|
class MetricsController < ActionController::Base
|
2017-07-03 11:09:34 -04:00
|
|
|
include RequiresWhitelistedMonitoringClient
|
2017-05-23 10:23:43 -04:00
|
|
|
|
2017-05-19 11:03:10 -04:00
|
|
|
protect_from_forgery with: :exception
|
2017-05-23 10:23:43 -04:00
|
|
|
|
2017-05-29 08:19:43 -04:00
|
|
|
def index
|
2017-09-25 17:38:34 -04:00
|
|
|
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
|
2018-01-11 11:34:01 -05:00
|
|
|
|
2017-09-25 17:38:34 -04:00
|
|
|
render text: response, content_type: 'text/plain; version=0.0.4'
|
2017-05-19 11:03:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-05-23 09:42:36 -04:00
|
|
|
def metrics_service
|
|
|
|
@metrics_service ||= MetricsService.new
|
2017-05-19 12:27:36 -04:00
|
|
|
end
|
2017-05-19 11:03:10 -04:00
|
|
|
end
|