2017-05-19 11:03:10 -04:00
|
|
|
class MetricsController < ActionController::Base
|
2017-05-23 10:23:43 -04:00
|
|
|
include RequiresHealthToken
|
|
|
|
|
2017-05-19 11:03:10 -04:00
|
|
|
protect_from_forgery with: :exception
|
2017-05-23 10:23:43 -04:00
|
|
|
|
2017-05-23 09:42:36 -04:00
|
|
|
before_action :validate_prometheus_metrics
|
2017-05-19 11:03:10 -04:00
|
|
|
|
2017-05-29 08:19:43 -04:00
|
|
|
def index
|
|
|
|
render text: metrics_service.metrics_text, content_type: 'text/plain; verssion=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-23 09:42:36 -04:00
|
|
|
def validate_prometheus_metrics
|
|
|
|
render_404 unless Gitlab::Metrics.prometheus_metrics_enabled?
|
2017-05-19 11:03:10 -04:00
|
|
|
end
|
|
|
|
end
|