File tree Expand file tree Collapse file tree 3 files changed +7
-20
lines changed Expand file tree Collapse file tree 3 files changed +7
-20
lines changed Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ func NewQuerierHandler(
204
204
InflightRequests : inflightRequests ,
205
205
}
206
206
cacheGenHeaderMiddleware := getHTTPCacheGenNumberHeaderSetterMiddleware (tombstonesLoader )
207
- middlewares := middleware .Merge (fakeRemoteAddr (), inst , cacheGenHeaderMiddleware )
207
+ middlewares := middleware .Merge (inst , cacheGenHeaderMiddleware )
208
208
router .Use (middlewares .Wrap )
209
209
210
210
promRouter := route .New ().WithPrefix (cfg .ServerPrefix + cfg .PrometheusHTTPPrefix + "/api/v1" )
@@ -227,9 +227,7 @@ func NewQuerierHandler(
227
227
// A prefix is fine because external routes will be registered explicitly
228
228
router .PathPrefix (cfg .LegacyHTTPPrefix + "/api/v1/" ).Handler (legacyPromRouter )
229
229
230
- // Since we have a new router and the request will not go trough the default server
231
- // HTTP middleware stack, we need to add a middleware to extract the trace context
232
- // from the HTTP headers and inject it into the Go context.
230
+ // Add a middleware to extract the trace context and add a header.
233
231
return nethttp .MiddlewareFunc (opentracing .GlobalTracer (), router .ServeHTTP , nethttp .OperationNameFunc (func (r * http.Request ) string {
234
232
return "internalQuerier"
235
233
}))
Original file line number Diff line number Diff line change @@ -10,22 +10,6 @@ import (
10
10
"github.com/cortexproject/cortex/pkg/querier/queryrange"
11
11
)
12
12
13
- // Latest Prometheus requires r.RemoteAddr to be set to addr:port, otherwise it reject the request.
14
- // Requests to Querier sometimes doesn't have that (if they are fetched from Query-Frontend).
15
- // Prometheus uses this when logging queries to QueryLogger, but Cortex doesn't call engine.SetQueryLogger to set one.
16
- //
17
- // Can be removed when (if) https://github.com/prometheus/prometheus/pull/6840 is merged.
18
- func fakeRemoteAddr () middleware.Interface {
19
- return middleware .Func (func (next http.Handler ) http.Handler {
20
- return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
21
- if r .RemoteAddr == "" {
22
- r .RemoteAddr = "127.0.0.1:8888"
23
- }
24
- next .ServeHTTP (w , r )
25
- })
26
- })
27
- }
28
-
29
13
// middleware for setting cache gen header to let consumer of response know all previous responses could be invalid due to delete operation
30
14
func getHTTPCacheGenNumberHeaderSetterMiddleware (cacheGenNumbersLoader * purger.TombstonesLoader ) middleware.Interface {
31
15
return middleware .Func (func (next http.Handler ) http.Handler {
Original file line number Diff line number Diff line change @@ -206,13 +206,17 @@ func (t *Cortex) initQueryable() (serv services.Service, err error) {
206
206
207
207
// initQuerier registers an internal HTTP router with a Prometheus API backed by the
208
208
// Cortex Queryable. Then it does one of the following:
209
+ //
209
210
// 1. Query-Frontend Enabled: If Cortex has an All or QueryFrontend target, the internal
210
211
// HTTP router is wrapped with Tenant ID parsing middleware and passed to the frontend
211
212
// worker.
213
+ //
212
214
// 2. Querier Standalone: The querier will register the internal HTTP router with the external
213
215
// HTTP router for the Prometheus API routes. Then the external HTTP server will be passed
214
216
// as a http.Handler to the frontend worker.
217
+ //
215
218
// Route Diagram:
219
+ //
216
220
// │ query
217
221
// │ request
218
222
// │
@@ -249,6 +253,7 @@ func (t *Cortex) initQueryable() (serv services.Service, err error) {
249
253
// └──────────────────────│ Prometheus API │
250
254
// │ │
251
255
// └──────────────────┘
256
+ //
252
257
func (t * Cortex ) initQuerier () (serv services.Service , err error ) {
253
258
// Create a internal HTTP handler that is configured with the Prometheus API routes and points
254
259
// to a Prometheus API struct instantiated with the Cortex Queryable.
You can’t perform that action at this time.
0 commit comments