@@ -65,19 +65,32 @@ func New(logger log.Logger, reg *prometheus.Registry, opts ...Option) Server {
65
65
66
66
registerProber (r , p )
67
67
68
- uiPath := "/ui/metrics/v1"
69
-
70
- r .Get ("/" , func (w http.ResponseWriter , r * http.Request ) {
71
- http .Redirect (w , r , path .Join (uiPath , "graph" ), http .StatusMovedPermanently )
72
- })
73
-
74
68
r .Get ("/metrics" , func (w http.ResponseWriter , r * http.Request ) {
75
69
promhttp .InstrumentMetricHandler (reg , promhttp .HandlerFor (reg , promhttp.HandlerOpts {})).ServeHTTP (w , r )
76
70
})
77
71
78
72
if options .metricsUIEndpoint != nil {
73
+ uiPath := "/ui/metrics/v1"
74
+
79
75
r .Get (path .Join (uiPath , "*" ),
80
76
ins .newHandler ("ui" , proxy .New (logger , uiPath , options .metricsUIEndpoint , options .proxyOptions ... )))
77
+
78
+ r .Get ("/" , func (w http.ResponseWriter , r * http.Request ) {
79
+ http .Redirect (w , r , path .Join (uiPath , "graph" ), http .StatusMovedPermanently )
80
+ })
81
+
82
+ // NOTICE: Following redirects added to be compatible with existing Read UI.
83
+ // Paths are explicitly specified to prevent unnecessary request to read handler.
84
+ for _ , p := range []string {
85
+ "graph" ,
86
+ "stores" ,
87
+ "status" ,
88
+ } {
89
+ p := p
90
+ r .Get (path .Join ("/" , p ), func (w http.ResponseWriter , r * http.Request ) {
91
+ http .Redirect (w , r , path .Join (uiPath , p ), http .StatusMovedPermanently )
92
+ })
93
+ }
81
94
}
82
95
83
96
namespace := "/api/metrics/v1"
@@ -98,20 +111,6 @@ func New(logger log.Logger, reg *prometheus.Registry, opts ...Option) Server {
98
111
ins .newHandler ("write" , proxy .New (logger , path .Join (namespace , writePath ), options .metricsWriteEndpoint , options .proxyOptions ... )))
99
112
})
100
113
101
- // NOTICE: Following redirects added to be compatible with existing Read UI.
102
- // Paths are explicitly specified to prevent unnecessary request to read handler.
103
- r .Get ("/graph" , func (w http.ResponseWriter , r * http.Request ) {
104
- http .Redirect (w , r , "/ui/v1/metrics/graph" , http .StatusMovedPermanently )
105
- })
106
-
107
- r .Get ("/stores" , func (w http.ResponseWriter , r * http.Request ) {
108
- http .Redirect (w , r , "/ui/v1/metrics/stores" , http .StatusMovedPermanently )
109
- })
110
-
111
- r .Get ("/status" , func (w http.ResponseWriter , r * http.Request ) {
112
- http .Redirect (w , r , "/ui/v1/metrics/status" , http .StatusMovedPermanently )
113
- })
114
-
115
114
p .Healthy ()
116
115
117
116
return Server {
0 commit comments