-
+
|
{health.toUpperCase()}
diff --git a/web/ui/react-app/src/pages/targets/__testdata__/testdata.ts b/web/ui/react-app/src/pages/targets/__testdata__/testdata.ts
index 0a6ed47e86..53f6a7e48d 100644
--- a/web/ui/react-app/src/pages/targets/__testdata__/testdata.ts
+++ b/web/ui/react-app/src/pages/targets/__testdata__/testdata.ts
@@ -20,6 +20,7 @@ export const targetGroups: ScrapePools = Object.freeze({
},
scrapePool: 'blackbox',
scrapeUrl: 'http://127.0.0.1:9115/probe?module=http_2xx&target=http%3A%2F%2Fprometheus.io',
+ globalUrl: 'http://localhost.localdomain:9115/probe?module=http_2xx&target=http%3A%2F%2Fprometheus.io',
lastError: '',
lastScrape: '2019-11-04T11:52:14.759299-07:00',
lastScrapeDuration: 36560147,
@@ -39,6 +40,7 @@ export const targetGroups: ScrapePools = Object.freeze({
},
scrapePool: 'blackbox',
scrapeUrl: 'http://127.0.0.1:9115/probe?module=http_2xx&target=https%3A%2F%2Fprometheus.io',
+ globalUrl: 'http://localhost.localdomain:9115/probe?module=http_2xx&target=https%3A%2F%2Fprometheus.io',
lastError: '',
lastScrape: '2019-11-04T11:52:24.731096-07:00',
lastScrapeDuration: 49448763,
@@ -58,6 +60,7 @@ export const targetGroups: ScrapePools = Object.freeze({
},
scrapePool: 'blackbox',
scrapeUrl: 'http://127.0.0.1:9115/probe?module=http_2xx&target=http%3A%2F%2Fexample.com%3A8080',
+ globalUrl: 'http://localhost.localdomain:9115/probe?module=http_2xx&target=http%3A%2F%2Fexample.com%3A8080',
lastError: '',
lastScrape: '2019-11-04T11:52:13.516654-07:00',
lastScrapeDuration: 120916592,
@@ -81,6 +84,7 @@ export const targetGroups: ScrapePools = Object.freeze({
},
scrapePool: 'node_exporter',
scrapeUrl: 'http://localhost:9100/metrics',
+ globalUrl: 'http://localhost.localdomain:9100/metrics',
lastError: '',
lastScrape: '2019-11-04T11:52:14.145703-07:00',
lastScrapeDuration: 3842307,
@@ -104,6 +108,7 @@ export const targetGroups: ScrapePools = Object.freeze({
},
scrapePool: 'prometheus',
scrapeUrl: 'http://localhost:9090/metrics',
+ globalUrl: 'http://localhost.localdomain:9000/metrics',
lastError: '',
lastScrape: '2019-11-04T11:52:18.479731-07:00',
lastScrapeDuration: 4050976,
diff --git a/web/ui/react-app/src/pages/targets/target.ts b/web/ui/react-app/src/pages/targets/target.ts
index 509bb98037..909c67e7b6 100644
--- a/web/ui/react-app/src/pages/targets/target.ts
+++ b/web/ui/react-app/src/pages/targets/target.ts
@@ -7,6 +7,7 @@ export interface Target {
labels: Labels;
scrapePool: string;
scrapeUrl: string;
+ globalUrl: string;
lastError: string;
lastScrape: string;
lastScrapeDuration: number;
diff --git a/web/web.go b/web/web.go
index 732702a0b9..3a3fedfb46 100644
--- a/web/web.go
+++ b/web/web.go
@@ -70,24 +70,20 @@ import (
"github.com/prometheus/prometheus/web/ui"
)
-var (
- localhostRepresentations = []string{"127.0.0.1", "localhost"}
-
- // Paths that are handled by the React / Reach router that should all be served the main React app's index.html.
- reactRouterPaths = []string{
- "/",
- "/alerts",
- "/config",
- "/flags",
- "/graph",
- "/rules",
- "/service-discovery",
- "/status",
- "/targets",
- "/tsdb-status",
- "/version",
- }
-)
+// Paths that are handled by the React / Reach router that should all be served the main React app's index.html.
+var reactRouterPaths = []string{
+ "/",
+ "/alerts",
+ "/config",
+ "/flags",
+ "/graph",
+ "/rules",
+ "/service-discovery",
+ "/status",
+ "/targets",
+ "/tsdb-status",
+ "/version",
+}
// withStackTrace logs the stack trace in case the request panics. The function
// will re-raise the error which will then be handled by the net/http package.
@@ -300,6 +296,11 @@ func New(logger log.Logger, o *Options) *Handler {
return *h.config
},
o.Flags,
+ api_v1.GlobalURLOptions{
+ ListenAddress: o.ListenAddress,
+ Host: o.ExternalURL.Host,
+ Scheme: o.ExternalURL.Scheme,
+ },
h.testReady,
func() api_v1.TSDBAdmin {
return h.options.TSDB()
@@ -973,7 +974,7 @@ func tmplFuncs(consolesPath string, opts *Options) template_text.FuncMap {
if err != nil {
return u
}
- for _, lhr := range localhostRepresentations {
+ for _, lhr := range api_v1.LocalhostRepresentations {
if host == lhr {
_, ownPort, err := net.SplitHostPort(opts.ListenAddress)
if err != nil {
diff --git a/web/web_test.go b/web/web_test.go
index 8a1f70bdd0..f9e6b1413a 100644
--- a/web/web_test.go
+++ b/web/web_test.go
@@ -305,7 +305,11 @@ func TestRoutePrefix(t *testing.T) {
Notifier: nil,
RoutePrefix: "/prometheus",
EnableAdminAPI: true,
- TSDB: func() *libtsdb.DB { return db },
+ ExternalURL: &url.URL{
+ Host: "localhost.localdomain:9090",
+ Scheme: "http",
+ },
+ TSDB: func() *libtsdb.DB { return db },
}
opts.Flags = map[string]string{}
@@ -391,7 +395,12 @@ func TestDebugHandler(t *testing.T) {
{"/foo", "/bar/debug/pprof/goroutine", 404},
} {
opts := &Options{
- RoutePrefix: tc.prefix,
+ RoutePrefix: tc.prefix,
+ ListenAddress: "somehost:9090",
+ ExternalURL: &url.URL{
+ Host: "localhost.localdomain:9090",
+ Scheme: "http",
+ },
}
handler := New(nil, opts)
handler.Ready()
@@ -411,7 +420,14 @@ func TestDebugHandler(t *testing.T) {
func TestHTTPMetrics(t *testing.T) {
t.Parallel()
- handler := New(nil, &Options{RoutePrefix: "/"})
+ handler := New(nil, &Options{
+ RoutePrefix: "/",
+ ListenAddress: "somehost:9090",
+ ExternalURL: &url.URL{
+ Host: "localhost.localdomain:9090",
+ Scheme: "http",
+ },
+ })
getReady := func() int {
t.Helper()
w := httptest.NewRecorder()
|