debian-mirror-gitlab/app/controllers/metrics_controller.rb

39 lines
1 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
# rubocop:disable Rails/ApplicationController
2017-09-10 17:25:29 +05:30
class MetricsController < ActionController::Base
include RequiresWhitelistedMonitoringClient
2018-11-08 19:23:39 +05:30
protect_from_forgery with: :exception, prepend: true
2017-09-10 17:25:29 +05:30
def index
2018-03-17 18:26:18 +05:30
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
2019-02-15 15:39:39 +05:30
render plain: response, content_type: 'text/plain; version=0.0.4'
2017-09-10 17:25:29 +05:30
end
2021-03-08 18:12:59 +05:30
def system
render json: system_metrics
end
2017-09-10 17:25:29 +05:30
private
def metrics_service
@metrics_service ||= MetricsService.new
end
2021-03-08 18:12:59 +05:30
def system_metrics
Gitlab::Metrics::System.summary.merge(
2021-09-30 23:02:18 +05:30
worker_id: ::Prometheus::PidProvider.worker_id
2021-03-08 18:12:59 +05:30
)
end
2017-09-10 17:25:29 +05:30
end
2022-10-11 01:57:18 +05:30
# rubocop:enable Rails/ApplicationController