@@ -66,8 +66,6 @@ type Handler struct {
6666 querySeconds * prometheus.CounterVec
6767 querySeries * prometheus.CounterVec
6868 queryBytes * prometheus.CounterVec
69- //totalQueries *prometheus.CounterVec
70- //cachedHits *prometheus.CounterVec
7169 totalQueries prometheus.Counter
7270 cachedHits prometheus.Counter
7371 activeUsers * util.ActiveUsersCleanupService
@@ -123,16 +121,6 @@ func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logge
123121 Help : "Size of all chunks fetched to execute a query in bytes." ,
124122 }, []string {"user" })
125123
126- //h.totalQueries = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
127- // Name: "cortex_queries_total",
128- // Help: "Total number of queries.",
129- //}, []string{})
130- //
131- //h.cachedHits = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
132- // Name: "cortex_queries_hits_total",
133- // Help: "Total number of queries that hit the cache.",
134- //}, []string{})
135-
136124 h .totalQueries = promauto .With (reg ).NewCounter (prometheus.CounterOpts {
137125 Name : "cortex_queries_total" ,
138126 Help : "Total number of queries." ,
@@ -170,6 +158,8 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
170158 var ctx context.Context
171159 stats , ctx = querier_stats .ContextWithEmptyStats (r .Context ())
172160 r = r .WithContext (ctx )
161+ // Increment total queries
162+ f .totalQueries .Inc ()
173163 level .Info (util_log .WithContext (r .Context (), f .log )).Log ("msg" , "QUERY STATS ENABLED, COUNTERS INSTANTIATED" )
174164 }
175165
@@ -182,15 +172,6 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
182172 r .Body = http .MaxBytesReader (w , r .Body , f .cfg .MaxBodySize )
183173 r .Body = io .NopCloser (io .TeeReader (r .Body , & buf ))
184174
185- // Increment total queries
186- //f.totalQueries.WithLabelValues("").Add(float64(1))
187-
188- if f .totalQueries != nil {
189- f .totalQueries .Inc ()
190- } else {
191- level .Info (util_log .WithContext (r .Context (), f .log )).Log ("msg" , "totalQueries is nil" )
192- }
193-
194175 // Check if caching is enabled
195176 if f .lru != nil {
196177 // Store query expression
@@ -216,7 +197,7 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
216197 if value , ok := f .lru .Get (queryExpressionNormalized ); ok && value .(int ) >= queryExpressionRangeLength {
217198 w .WriteHeader (http .StatusForbidden )
218199 level .Warn (util_log .WithContext (r .Context (), f .log )).Log ("msg" , "FOUND QUERY IN CACHE: CAUSED ERROR: " , "query expression" , queryExpressionNormalized )
219- // f.cachedHits.WithLabelValues("").Add(float64(1) )
200+ f .cachedHits .Inc ( )
220201 return
221202 }
222203 }
0 commit comments