Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix label values query when server.http_path_prefix is set #15978

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions pkg/querier/queryrange/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,32 +506,34 @@ func getOperation(path string) string {
switch {
case strings.HasSuffix(path, "/query_range") || strings.HasSuffix(path, "/prom/query"):
return QueryRangeOp
case strings.HasSuffix(path, "/query"):
return InstantQueryOp
case strings.HasSuffix(path, "/series"):
return SeriesOp
case strings.HasSuffix(path, "/labels") || strings.HasSuffix(path, "/label"):
return LabelNamesOp
case strings.HasSuffix(path, "/v1/query"):
return InstantQueryOp
case path == "/loki/api/v1/index/stats":
case strings.HasSuffix(path, "/index/stats"):
return IndexStatsOp
case path == "/loki/api/v1/index/volume":
case strings.HasSuffix(path, "/index/volume"):
return VolumeOp
case path == "/loki/api/v1/index/volume_range":
case strings.HasSuffix(path, "/index/volume_range"):
return VolumeRangeOp
case path == "/loki/api/v1/index/shards":
case strings.HasSuffix(path, "/index/shards"):
return IndexShardsOp
case path == "/loki/api/v1/detected_fields":
case strings.HasSuffix(path, "/detected_fields"):
return DetectedFieldsOp
case strings.HasSuffix(path, "/patterns"):
return PatternsQueryOp
case strings.HasSuffix(path, "/detected_labels"):
return DetectedLabelsOp
case strings.HasSuffix(path, "/values"):
if strings.HasPrefix(path, "/loki/api/v1/label") || strings.HasPrefix(path, "/api/prom/label") {
if strings.Contains(path, "/label") {
return LabelNamesOp
}

return DetectedFieldsOp
case path == "/loki/api/v1/patterns":
return PatternsQueryOp
case path == "/loki/api/v1/detected_labels":
return DetectedLabelsOp
if strings.Contains(path, "/detected_field") {
return DetectedFieldsOp
}
return ""
default:
return ""
}
Expand Down
13 changes: 8 additions & 5 deletions pkg/querier/queryrange/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1273,11 +1273,14 @@ func Test_getOperation(t *testing.T) {
},
}

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := getOperation(tc.path)
assert.Equal(t, tc.expectedOp, got)
})
for _, pathPrefix := range []string{"", "/proxy"} {
for _, tc := range cases {
name := tc.name + pathPrefix + tc.path
t.Run(name, func(t *testing.T) {
got := getOperation(pathPrefix + tc.path)
assert.Equal(t, tc.expectedOp, got)
})
}
}
}

Expand Down
Loading