Skip to content

Commit 5f28151

Browse files
authored
Added fallback to root testing (#1431)
1 parent ca7fa30 commit 5f28151

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

restapi/admin_info.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,9 +936,26 @@ func testPrometheusURL(url string) bool {
936936
response, err := GetConsoleHTTPClient().Do(req)
937937

938938
if err != nil {
939-
LogError("Non reachable Prometheus URL: (%v)", err)
940-
return false
939+
LogError("Default Prometheus URL not reachable, trying root testing: (%v)", err)
940+
941+
newTestURL := req.URL.Scheme + "://" + req.URL.Host + "/-/healthy"
942+
943+
req2, err := http.NewRequestWithContext(ctx, http.MethodGet, newTestURL, nil)
944+
945+
if err != nil {
946+
LogError("Error Building Root Request: (%v)", err)
947+
return false
948+
}
949+
950+
rootResponse, err := GetConsoleHTTPClient().Do(req2)
951+
952+
if err != nil {
953+
// URL & Root tests didn't work. Prometheus not reachable
954+
LogError("Root Prometheus URL not reachable: (%v)", err)
955+
return false
956+
}
941957

958+
return rootResponse.StatusCode == http.StatusOK
942959
}
943960

944961
return response.StatusCode == http.StatusOK

0 commit comments

Comments
 (0)