Skip to content

Commit a9b6c20

Browse files
authored
Add a format query label value to queries total metric (#6925)
Signed-off-by: SungJin1212 <[email protected]>
1 parent 49099a3 commit a9b6c20

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
* [ENHANCEMENT] Ring: Add zone label to ring_members metric. #6900
6363
* [ENHANCEMENT] Ingester: Add new metric `cortex_ingester_push_errors_total` to track reasons for ingester request failures. #6901
6464
* [ENHANCEMENT] Parquet Storage: Allow Parquet Queryable to disable fallback to Store Gateway. #6920
65+
* [ENHANCEMENT] Query Frontend: Add a `format_query` label value to the `op` label at `cortex_query_frontend_queries_total` metric. #6925
6566
* [BUGFIX] Ingester: Avoid error or early throttling when READONLY ingesters are present in the ring #6517
6667
* [BUGFIX] Ingester: Fix labelset data race condition. #6573
6768
* [BUGFIX] Compactor: Cleaner should not put deletion marker for blocks with no-compact marker. #6576

pkg/querier/tripperware/roundtrip.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const (
4646
opTypeLabelValues = "label_values"
4747
opTypeMetadata = "metadata"
4848
opTypeQueryExemplars = "query_exemplars"
49+
opTypeFormatQuery = "format_query"
4950
)
5051

5152
// HandlerFunc is like http.HandlerFunc, but for Handler.
@@ -152,6 +153,7 @@ func NewQueryTripperware(
152153
isLabelValues := strings.HasSuffix(r.URL.Path, "/values")
153154
isMetadata := strings.HasSuffix(r.URL.Path, "/metadata")
154155
isQueryExemplars := strings.HasSuffix(r.URL.Path, "/query_exemplars")
156+
isFormatQuery := strings.HasSuffix(r.URL.Path, "/format_query")
155157

156158
op := opTypeQuery
157159
switch {
@@ -169,6 +171,8 @@ func NewQueryTripperware(
169171
op = opTypeMetadata
170172
case isQueryExemplars:
171173
op = opTypeQueryExemplars
174+
case isFormatQuery:
175+
op = opTypeFormatQuery
172176
}
173177

174178
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
@@ -38,6 +38,7 @@ const (
3838
labelNamesQuery = "/api/v1/labels"
3939
labelValuesQuery = "/api/v1/label/label/values"
4040
metadataQuery = "/api/v1/metadata"
41+
formatQuery = "/api/v1/format_query?query=foo/bar"
4142

4243
responseBody = `{"status":"success","data":{"resultType":"matrix","result":[{"metric":{"foo":"bar"},"values":[[1536673680,"137"],[1536673780,"137"]]}]}}`
4344
instantResponseBody = `{"status":"success","data":{"resultType":"vector","result":[{"metric":{"foo":"bar"},"values":[[1536673680,"137"],[1536673780,"137"]]}]}}`
@@ -229,6 +230,18 @@ cortex_query_frontend_queries_total{op="remote_read", source="api", user="1"} 1
229230
# HELP cortex_query_frontend_queries_total Total queries sent per tenant.
230231
# TYPE cortex_query_frontend_queries_total counter
231232
cortex_query_frontend_queries_total{op="query_range", source="api", user="1"} 1
233+
`,
234+
},
235+
{
236+
path: formatQuery,
237+
expectedBody: "bar",
238+
limits: defaultOverrides,
239+
maxSubQuerySteps: 11000,
240+
userAgent: "dummyUserAgent/1.2",
241+
expectedMetric: `
242+
# HELP cortex_query_frontend_queries_total Total queries sent per tenant.
243+
# TYPE cortex_query_frontend_queries_total counter
244+
cortex_query_frontend_queries_total{op="format_query", source="api", user="1"} 1
232245
`,
233246
},
234247
{

0 commit comments

Comments
 (0)