diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-10 12:25:30 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-25 16:05:56 +0300 |
commit | 2061414054ce43aa6d53d1be3f602114e5a336d2 (patch) | |
tree | c32e83fcd76cd279171117f3ff282ef54f5308a2 /app/controllers | |
parent | 78de1c059ac588df4ba1ef352b28e5b1c6102804 (diff) |
Additional metrics initial work, with working metrics listing, but without actoual metrics mesurements
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/prometheus_controller.rb | 22 |
2 files changed, 28 insertions, 0 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index efe83776834..6d230e84ef7 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -129,6 +129,12 @@ class Projects::EnvironmentsController < Projects::ApplicationController end end + def additional_metrics + additional_metrics = environment.additional_metrics || {} + + render json: additional_metrics, status: additional_metrics.any? ? :ok : :no_content + end + private def verify_api_request! diff --git a/app/controllers/projects/prometheus_controller.rb b/app/controllers/projects/prometheus_controller.rb new file mode 100644 index 00000000000..74e247535d5 --- /dev/null +++ b/app/controllers/projects/prometheus_controller.rb @@ -0,0 +1,22 @@ +class Projects::PrometheusController < Projects::ApplicationController + before_action :authorize_read_project! + + def active_metrics + return render_404 unless has_prometheus_metrics? + matched_metrics = prometheus_service.reactive_query(Gitlab::Prometheus::Queries::MatchedMetricsQuery.name, &:itself) + + if matched_metrics + render json: matched_metrics, status: :ok + else + head :no_content + end + end + + def prometheus_service + project.monitoring_service + end + + def has_prometheus_metrics? + prometheus_service&.respond_to?(:reactive_query) + end +end |