Skip to content

Commit

Permalink
fix(web-app): Fix Grafana detection due to HEAD request (kubeflow#1541)
Browse files Browse the repository at this point in the history
We should use a GET request to try and detect if Grafana is exposed. The
frontend should consider the Grafana endpoint to be working only if the
request to the endpoint returns a list.

Signed-off-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>
  • Loading branch information
kimwnasptd authored Apr 19, 2021
1 parent 7fc4bbb commit e0440c8
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,27 @@ export class ServerInfoComponent implements OnInit, OnDestroy {
});

// don't show a METRICS tab if Grafana is not exposed
console.log('Checking if Grafana endpoint is exposed');
const grafanaApi = environment.grafanaPrefix + '/api/search';

this.http
.head(environment.grafanaPrefix)
.get(grafanaApi)
.pipe(timeout(1000))
.subscribe({
next: () => {
next: resp => {
if (!Array.isArray(resp)) {
console.log(
'Response from the Grafana endpoint was not as expected.',
);
this.grafanaFound = false;
return;
}

console.log('Grafana endpoint detected. Will expose a metrics tab.');
this.grafanaFound = true;
},
error: () => {
console.log('Could not detect a Grafana endpoint..');
this.grafanaFound = false;
},
});
Expand Down

0 comments on commit e0440c8

Please sign in to comment.