@@ -42,32 +42,30 @@ var (
42
42
)
43
43
44
44
const (
45
- reasonRequestBodyTooLarge = "request_body_too_large"
46
- reasonResponseTooLarge = "response_too_large"
47
- reasonTooManyRequests = "too_many_requests"
48
- reasonTooLongRange = "too_long_range"
49
- reasonTooManySamples = "too_many_samples"
50
- reasonSeriesFetched = "series_fetched"
51
- reasonChunksFetched = "chunks_fetched"
52
- reasonChunkBytesFetched = "chunk_bytes_fetched"
53
- reasonDataBytesFetched = "data_bytes_fetched"
54
- reasonSeriesLimitStoreGateway = "series_limit_store_gateway"
55
- reasonChunksLimitStoreGateway = "chunks_limit_store_gateway"
56
- reasonBytesLimitStoreGateway = "bytes_limit_store_gateway"
57
- )
58
-
59
- var (
60
- LimitTooManySamples = `query processing would load too many samples into memory`
61
- LimitTooLongRange = `the query time range exceeds the limit`
62
- LimitSeriesFetched = `the query hit the max number of series limit`
63
- LimitChunksFetched = `the query hit the max number of chunks limit`
64
- LimitChunkBytesFetched = `the query hit the aggregated chunks size limit`
65
- LimitDataBytesFetched = `the query hit the aggregated data size limit`
45
+ reasonRequestBodySizeExceeded = "request_body_size_exceeded"
46
+ reasonResponseBodySizeExceeded = "response_body_size_exceeded"
47
+ reasonTooManyRequests = "too_many_requests"
48
+ reasonTimeRangeExceeded = "time_range_exceeded"
49
+ reasonTooManySamples = "too_many_samples"
50
+ reasonSeriesFetched = "series_fetched"
51
+ reasonChunksFetched = "chunks_fetched"
52
+ reasonChunkBytesFetched = "chunk_bytes_fetched"
53
+ reasonDataBytesFetched = "data_bytes_fetched"
54
+ reasonSeriesLimitStoreGateway = "store_gateway_series_limit"
55
+ reasonChunksLimitStoreGateway = "store_gateway_chunks_limit"
56
+ reasonBytesLimitStoreGateway = "store_gateway_bytes_limit"
57
+
58
+ limitTooManySamples = `query processing would load too many samples into memory`
59
+ limitTimeRangeExceeded = `the query time range exceeds the limit`
60
+ limitSeriesFetched = `the query hit the max number of series limit`
61
+ limitChunksFetched = `the query hit the max number of chunks limit`
62
+ limitChunkBytesFetched = `the query hit the aggregated chunks size limit`
63
+ limitDataBytesFetched = `the query hit the aggregated data size limit`
66
64
67
65
// Store gateway limits.
68
- LimitSeriesStoreGateway = `exceeded series limit`
69
- LimitChunksStoreGateway = `exceeded chunks limit`
70
- LimitBytesStoreGateway = `exceeded bytes limit`
66
+ limitSeriesStoreGateway = `exceeded series limit`
67
+ limitChunksStoreGateway = `exceeded chunks limit`
68
+ limitBytesStoreGateway = `exceeded bytes limit`
71
69
)
72
70
73
71
// Config for a Handler.
@@ -91,13 +89,13 @@ type Handler struct {
91
89
roundTripper http.RoundTripper
92
90
93
91
// Metrics.
94
- queriesCount * prometheus.CounterVec
95
- querySeconds * prometheus.CounterVec
96
- querySeries * prometheus.CounterVec
97
- queryChunkBytes * prometheus.CounterVec
98
- queryDataBytes * prometheus.CounterVec
99
- discardedQueries * prometheus.CounterVec
100
- activeUsers * util.ActiveUsersCleanupService
92
+ queriesCount * prometheus.CounterVec
93
+ querySeconds * prometheus.CounterVec
94
+ querySeries * prometheus.CounterVec
95
+ queryChunkBytes * prometheus.CounterVec
96
+ queryDataBytes * prometheus.CounterVec
97
+ rejectedQueries * prometheus.CounterVec
98
+ activeUsers * util.ActiveUsersCleanupService
101
99
}
102
100
103
101
// NewHandler creates a new frontend handler.
@@ -134,10 +132,10 @@ func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logge
134
132
Help : "Size of all data fetched to execute a query in bytes." ,
135
133
}, []string {"user" })
136
134
137
- h .discardedQueries = prometheus .NewCounterVec (
135
+ h .rejectedQueries = prometheus .NewCounterVec (
138
136
prometheus.CounterOpts {
139
- Name : "cortex_discarded_queries_total " ,
140
- Help : "The total number of queries that were discarded ." ,
137
+ Name : "cortex_rejected_queries_total " ,
138
+ Help : "The total number of queries that were rejected ." ,
141
139
},
142
140
[]string {"reason" , "user" },
143
141
)
@@ -148,8 +146,8 @@ func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logge
148
146
h .querySeries .DeleteLabelValues (user )
149
147
h .queryChunkBytes .DeleteLabelValues (user )
150
148
h .queryDataBytes .DeleteLabelValues (user )
151
- if err := util .DeleteMatchingLabels (h .discardedQueries , map [string ]string {"user" : user }); err != nil {
152
- level .Warn (log ).Log ("msg" , "failed to remove cortex_discarded_queries_total metric for user" , "user" , user , "err" , err )
149
+ if err := util .DeleteMatchingLabels (h .rejectedQueries , map [string ]string {"user" : user }); err != nil {
150
+ level .Warn (log ).Log ("msg" , "failed to remove cortex_rejected_queries_total metric for user" , "user" , user , "err" , err )
153
151
}
154
152
})
155
153
// If cleaner stops or fail, we will simply not clean the metrics for inactive users.
@@ -198,7 +196,7 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
198
196
if err := r .ParseForm (); err != nil {
199
197
writeError (w , err )
200
198
if f .cfg .QueryStatsEnabled && util .IsRequestBodyTooLarge (err ) {
201
- f .discardedQueries .WithLabelValues (reasonRequestBodyTooLarge , userID ).Inc ()
199
+ f .rejectedQueries .WithLabelValues (reasonRequestBodySizeExceeded , userID ).Inc ()
202
200
}
203
201
return
204
202
}
@@ -360,35 +358,34 @@ func (f *Handler) reportQueryStats(r *http.Request, userID string, queryString u
360
358
}
361
359
362
360
var reason string
363
- // 413, 422 or 429.
364
361
if statusCode == http .StatusTooManyRequests {
365
362
reason = reasonTooManyRequests
366
363
} else if statusCode == http .StatusRequestEntityTooLarge {
367
- reason = reasonResponseTooLarge
364
+ reason = reasonResponseBodySizeExceeded
368
365
} else if statusCode == http .StatusUnprocessableEntity {
369
366
errMsg := error .Error ()
370
- if strings .Contains (errMsg , LimitTooManySamples ) {
367
+ if strings .Contains (errMsg , limitTooManySamples ) {
371
368
reason = reasonTooManySamples
372
- } else if strings .Contains (errMsg , LimitTooLongRange ) {
373
- reason = reasonTooLongRange
374
- } else if strings .Contains (errMsg , LimitSeriesFetched ) {
369
+ } else if strings .Contains (errMsg , limitTimeRangeExceeded ) {
370
+ reason = reasonTimeRangeExceeded
371
+ } else if strings .Contains (errMsg , limitSeriesFetched ) {
375
372
reason = reasonSeriesFetched
376
- } else if strings .Contains (errMsg , LimitChunksFetched ) {
373
+ } else if strings .Contains (errMsg , limitChunksFetched ) {
377
374
reason = reasonChunksFetched
378
- } else if strings .Contains (errMsg , LimitChunkBytesFetched ) {
375
+ } else if strings .Contains (errMsg , limitChunkBytesFetched ) {
379
376
reason = reasonChunkBytesFetched
380
- } else if strings .Contains (errMsg , LimitDataBytesFetched ) {
377
+ } else if strings .Contains (errMsg , limitDataBytesFetched ) {
381
378
reason = reasonDataBytesFetched
382
- } else if strings .Contains (errMsg , LimitSeriesStoreGateway ) {
379
+ } else if strings .Contains (errMsg , limitSeriesStoreGateway ) {
383
380
reason = reasonSeriesLimitStoreGateway
384
- } else if strings .Contains (errMsg , LimitChunksStoreGateway ) {
381
+ } else if strings .Contains (errMsg , limitChunksStoreGateway ) {
385
382
reason = reasonChunksLimitStoreGateway
386
- } else if strings .Contains (errMsg , LimitBytesStoreGateway ) {
383
+ } else if strings .Contains (errMsg , limitBytesStoreGateway ) {
387
384
reason = reasonBytesLimitStoreGateway
388
385
}
389
386
}
390
387
if len (reason ) > 0 {
391
- f .discardedQueries .WithLabelValues (reason , userID ).Inc ()
388
+ f .rejectedQueries .WithLabelValues (reason , userID ).Inc ()
392
389
}
393
390
}
394
391
0 commit comments