Commit 683c7c48 authored by Ryan Cobb's avatar Ryan Cobb Committed by Peter Leitzen

Provide metrics dashboards path to cluster charts

This makes it so we provide `dashboard-endpoint` to cluster health
charts. This is needed so the frontend knows where to fetch cluster
dashboards.
parent 09cc6c76
...@@ -27,7 +27,7 @@ module EE ...@@ -27,7 +27,7 @@ module EE
def prometheus_proxy def prometheus_proxy
result = ::Prometheus::ProxyService.new( result = ::Prometheus::ProxyService.new(
clusterable.clusterable, cluster.cluster,
proxy_method, proxy_method,
proxy_path, proxy_path,
proxy_params proxy_params
......
...@@ -17,6 +17,7 @@ module EE ...@@ -17,6 +17,7 @@ module EE
{ {
'clusters-path': clusterable.index_path, 'clusters-path': clusterable.index_path,
'metrics-endpoint': clusterable.metrics_cluster_path(cluster, format: :json), 'metrics-endpoint': clusterable.metrics_cluster_path(cluster, format: :json),
'dashboard-endpoint': clusterable.metrics_dashboard_path(cluster),
'documentation-path': help_page_path('administration/monitoring/prometheus/index.md'), 'documentation-path': help_page_path('administration/monitoring/prometheus/index.md'),
'empty-getting-started-svg-path': image_path('illustrations/monitoring/getting_started.svg'), 'empty-getting-started-svg-path': image_path('illustrations/monitoring/getting_started.svg'),
'empty-loading-svg-path': image_path('illustrations/monitoring/loading.svg'), 'empty-loading-svg-path': image_path('illustrations/monitoring/loading.svg'),
......
...@@ -8,6 +8,10 @@ module EE ...@@ -8,6 +8,10 @@ module EE
raise NotImplementedError raise NotImplementedError
end end
def metrics_dashboard_path(cluster)
raise NotImplementedError
end
private private
override :multiple_clusters_available? override :multiple_clusters_available?
......
...@@ -16,6 +16,11 @@ module EE ...@@ -16,6 +16,11 @@ module EE
environments_group_cluster_path(clusterable, cluster) environments_group_cluster_path(clusterable, cluster)
end end
override :metrics_dashboard_path
def metrics_dashboard_path(cluster)
metrics_dashboard_group_cluster_path(clusterable, cluster)
end
private private
def can_read_cluster_environments? def can_read_cluster_environments?
......
...@@ -8,5 +8,10 @@ module EE ...@@ -8,5 +8,10 @@ module EE
def metrics_cluster_path(cluster, params = {}) def metrics_cluster_path(cluster, params = {})
metrics_admin_cluster_path(cluster, params) metrics_admin_cluster_path(cluster, params)
end end
override :metrics_dashboard_path
def metrics_dashboard_path(cluster)
metrics_dashboard_admin_cluster_path(cluster)
end
end end
end end
...@@ -8,5 +8,10 @@ module EE ...@@ -8,5 +8,10 @@ module EE
def metrics_cluster_path(cluster, params = {}) def metrics_cluster_path(cluster, params = {})
metrics_project_cluster_path(clusterable, cluster, params) metrics_project_cluster_path(clusterable, cluster, params)
end end
override :metrics_dashboard_path
def metrics_dashboard_path(cluster)
metrics_dashboard_project_cluster_path(clusterable, cluster)
end
end end
end end
...@@ -78,6 +78,7 @@ describe ClustersHelper do ...@@ -78,6 +78,7 @@ describe ClustersHelper do
is_expected.to match( is_expected.to match(
'clusters-path': clusterable_presenter.index_path, 'clusters-path': clusterable_presenter.index_path,
'metrics-endpoint': clusterable_presenter.metrics_cluster_path(cluster, format: :json), 'metrics-endpoint': clusterable_presenter.metrics_cluster_path(cluster, format: :json),
'dashboard-endpoint': clusterable_presenter.metrics_dashboard_path(cluster),
'documentation-path': help_page_path('administration/monitoring/prometheus/index.md'), 'documentation-path': help_page_path('administration/monitoring/prometheus/index.md'),
'empty-getting-started-svg-path': match_asset_path('/assets/illustrations/monitoring/getting_started.svg'), 'empty-getting-started-svg-path': match_asset_path('/assets/illustrations/monitoring/getting_started.svg'),
'empty-loading-svg-path': match_asset_path('/assets/illustrations/monitoring/loading.svg'), 'empty-loading-svg-path': match_asset_path('/assets/illustrations/monitoring/loading.svg'),
......
...@@ -14,4 +14,10 @@ describe InstanceClusterablePresenter do ...@@ -14,4 +14,10 @@ describe InstanceClusterablePresenter do
it { is_expected.to eq(metrics_admin_cluster_path(cluster)) } it { is_expected.to eq(metrics_admin_cluster_path(cluster)) }
end end
describe '#metrics_dashboard_path' do
subject { presenter.metrics_dashboard_path(cluster) }
it { is_expected.to eq(metrics_dashboard_admin_cluster_path(cluster)) }
end
end end
...@@ -40,4 +40,10 @@ describe GroupClusterablePresenter do ...@@ -40,4 +40,10 @@ describe GroupClusterablePresenter do
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
end end
describe '#metrics_dashboard_path' do
subject { presenter.metrics_dashboard_path(cluster) }
it { is_expected.to eq(metrics_dashboard_group_cluster_path(group, cluster)) }
end
end end
...@@ -14,4 +14,10 @@ describe ProjectClusterablePresenter do ...@@ -14,4 +14,10 @@ describe ProjectClusterablePresenter do
it { is_expected.to eq(metrics_project_cluster_path(project, cluster)) } it { is_expected.to eq(metrics_project_cluster_path(project, cluster)) }
end end
describe '#metrics_dashboard_path' do
subject { presenter.metrics_dashboard_path(cluster) }
it { is_expected.to eq(metrics_dashboard_project_cluster_path(project, cluster)) }
end
end end
...@@ -95,7 +95,7 @@ shared_examples 'cluster metrics' do ...@@ -95,7 +95,7 @@ shared_examples 'cluster metrics' do
context 'with valid requests' do context 'with valid requests' do
before do before do
allow(Prometheus::ProxyService).to receive(:new) allow(Prometheus::ProxyService).to receive(:new)
.with(clusterable, 'GET', 'query', expected_params) .with(cluster, 'GET', 'query', expected_params)
.and_return(prometheus_proxy_service) .and_return(prometheus_proxy_service)
allow(prometheus_proxy_service).to receive(:execute) allow(prometheus_proxy_service).to receive(:execute)
...@@ -112,7 +112,7 @@ shared_examples 'cluster metrics' do ...@@ -112,7 +112,7 @@ shared_examples 'cluster metrics' do
get :prometheus_proxy, params: prometheus_proxy_params get :prometheus_proxy, params: prometheus_proxy_params
expect(Prometheus::ProxyService).to have_received(:new) expect(Prometheus::ProxyService).to have_received(:new)
.with(clusterable, 'GET', 'query', expected_params) .with(cluster, 'GET', 'query', expected_params)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq(prometheus_json_body) expect(json_response).to eq(prometheus_json_body)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment