2017-05-10 05:25:30 -04:00
|
|
|
class Projects::PrometheusController < Projects::ApplicationController
|
|
|
|
before_action :authorize_read_project!
|
2017-05-25 10:19:54 -04:00
|
|
|
before_action :require_prometheus_metrics!
|
2017-05-10 05:25:30 -04:00
|
|
|
|
|
|
|
def active_metrics
|
2017-06-06 08:40:03 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
2017-06-16 14:48:34 -04:00
|
|
|
matched_metrics = project.prometheus_service.matched_metrics || {}
|
2017-06-06 20:36:59 -04:00
|
|
|
|
2017-06-06 08:40:03 -04:00
|
|
|
if matched_metrics.any?
|
|
|
|
render json: matched_metrics
|
|
|
|
else
|
|
|
|
head :no_content
|
|
|
|
end
|
|
|
|
end
|
2017-05-10 05:25:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-25 10:19:54 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def require_prometheus_metrics!
|
2017-06-16 14:48:34 -04:00
|
|
|
render_404 unless project.prometheus_service.present?
|
2017-05-25 10:19:54 -04:00
|
|
|
end
|
2017-05-10 05:25:30 -04:00
|
|
|
end
|