Skip to content

Commit 42b35fa

Browse files
authored
Add parse query op label to queries total metric (#6990)
Signed-off-by: SungJin1212 <[email protected]>
1 parent cc51a01 commit 42b35fa

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
* [ENHANCEMENT] Ingester: Add new metric `cortex_ingester_push_errors_total` to track reasons for ingester request failures. #6901
7070
* [ENHANCEMENT] Ring: Expose `detailed_metrics_enabled` for all rings. Default true. #6926
7171
* [ENHANCEMENT] Parquet Storage: Allow Parquet Queryable to disable fallback to Store Gateway. #6920
72-
* [ENHANCEMENT] Query Frontend: Add a `format_query` label value to the `op` label at `cortex_query_frontend_queries_total` metric. #6925
72+
* [ENHANCEMENT] Query Frontend: Add a `format_query` and `parse_query` labels value to the `op` label at `cortex_query_frontend_queries_total` metric. #6925 #6990
7373
* [ENHANCEMENT] API: add request ID injection to context to enable tracking requests across downstream services. #6895
7474
* [ENHANCEMENT] gRPC: Add gRPC Channelz monitoring. #6950
7575
* [ENHANCEMENT] Upgrade build image and Go version to 1.24.6. #6970 #6976

pkg/querier/tripperware/roundtrip.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const (
4747
opTypeMetadata = "metadata"
4848
opTypeQueryExemplars = "query_exemplars"
4949
opTypeFormatQuery = "format_query"
50+
opTypeParseQuery = "parse_query"
5051
)
5152

5253
// HandlerFunc is like http.HandlerFunc, but for Handler.
@@ -154,6 +155,7 @@ func NewQueryTripperware(
154155
isMetadata := strings.HasSuffix(r.URL.Path, "/metadata")
155156
isQueryExemplars := strings.HasSuffix(r.URL.Path, "/query_exemplars")
156157
isFormatQuery := strings.HasSuffix(r.URL.Path, "/format_query")
158+
isParseQuery := strings.HasSuffix(r.URL.Path, "/parse_query")
157159

158160
op := opTypeQuery
159161
switch {
@@ -173,6 +175,8 @@ func NewQueryTripperware(
173175
op = opTypeQueryExemplars
174176
case isFormatQuery:
175177
op = opTypeFormatQuery
178+
case isParseQuery:
179+
op = opTypeParseQuery
176180
}
177181

178182
tenantIDs, err := tenant.TenantIDs(r.Context())

pkg/querier/tripperware/roundtrip_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const (
3939
labelValuesQuery = "/api/v1/label/label/values"
4040
metadataQuery = "/api/v1/metadata"
4141
formatQuery = "/api/v1/format_query?query=foo/bar"
42+
parseQuery = "/api/v1/parse_query?query=foo/bar"
4243

4344
responseBody = `{"status":"success","data":{"resultType":"matrix","result":[{"metric":{"foo":"bar"},"values":[[1536673680,"137"],[1536673780,"137"]]}]}}`
4445
instantResponseBody = `{"status":"success","data":{"resultType":"vector","result":[{"metric":{"foo":"bar"},"values":[[1536673680,"137"],[1536673780,"137"]]}]}}`
@@ -242,6 +243,18 @@ cortex_query_frontend_queries_total{op="query_range", source="api", user="1"} 1
242243
# HELP cortex_query_frontend_queries_total Total queries sent per tenant.
243244
# TYPE cortex_query_frontend_queries_total counter
244245
cortex_query_frontend_queries_total{op="format_query", source="api", user="1"} 1
246+
`,
247+
},
248+
{
249+
path: parseQuery,
250+
expectedBody: "bar",
251+
limits: defaultOverrides,
252+
maxSubQuerySteps: 11000,
253+
userAgent: "dummyUserAgent/1.2",
254+
expectedMetric: `
255+
# HELP cortex_query_frontend_queries_total Total queries sent per tenant.
256+
# TYPE cortex_query_frontend_queries_total counter
257+
cortex_query_frontend_queries_total{op="parse_query", source="api", user="1"} 1
245258
`,
246259
},
247260
{

0 commit comments

Comments
 (0)