@@ -28,17 +28,18 @@ import (
28
28
)
29
29
30
30
const (
31
- queryPath = "/loki/api/v1/query"
32
- queryRangePath = "/loki/api/v1/query_range"
33
- labelsPath = "/loki/api/v1/labels"
34
- labelValuesPath = "/loki/api/v1/label/%s/values"
35
- seriesPath = "/loki/api/v1/series"
36
- tailPath = "/loki/api/v1/tail"
37
- statsPath = "/loki/api/v1/index/stats"
38
- volumePath = "/loki/api/v1/index/volume"
39
- volumeRangePath = "/loki/api/v1/index/volume_range"
40
- detectedFieldsPath = "/loki/api/v1/detected_fields"
41
- defaultAuthHeader = "Authorization"
31
+ queryPath = "/loki/api/v1/query"
32
+ queryRangePath = "/loki/api/v1/query_range"
33
+ labelsPath = "/loki/api/v1/labels"
34
+ labelValuesPath = "/loki/api/v1/label/%s/values"
35
+ seriesPath = "/loki/api/v1/series"
36
+ tailPath = "/loki/api/v1/tail"
37
+ statsPath = "/loki/api/v1/index/stats"
38
+ volumePath = "/loki/api/v1/index/volume"
39
+ volumeRangePath = "/loki/api/v1/index/volume_range"
40
+ detectedFieldsPath = "/loki/api/v1/detected_fields"
41
+ detectedFieldValuesPath = "/loki/api/v1/detected_field/%s/values"
42
+ defaultAuthHeader = "Authorization"
42
43
43
44
// HTTP header keys
44
45
HTTPScopeOrgID = "X-Scope-OrgID"
@@ -61,7 +62,7 @@ type Client interface {
61
62
GetStats (queryStr string , start , end time.Time , quiet bool ) (* logproto.IndexStatsResponse , error )
62
63
GetVolume (query * volume.Query ) (* loghttp.QueryResponse , error )
63
64
GetVolumeRange (query * volume.Query ) (* loghttp.QueryResponse , error )
64
- GetDetectedFields (queryStr string , fieldLimit , lineLimit int , start , end time.Time , step time.Duration , quiet bool ) (* loghttp.DetectedFieldsResponse , error )
65
+ GetDetectedFields (queryStr , fieldName string , fieldLimit , lineLimit int , start , end time.Time , step time.Duration , quiet bool ) (* loghttp.DetectedFieldsResponse , error )
65
66
}
66
67
67
68
// Tripperware can wrap a roundtripper.
@@ -234,15 +235,16 @@ func (c *DefaultClient) getVolume(path string, query *volume.Query) (*loghttp.Qu
234
235
}
235
236
236
237
func (c * DefaultClient ) GetDetectedFields (
237
- queryStr string ,
238
- fieldLimit , lineLimit int ,
238
+ queryStr , fieldName string ,
239
+ limit , lineLimit int ,
239
240
start , end time.Time ,
240
241
step time.Duration ,
241
242
quiet bool ,
242
243
) (* loghttp.DetectedFieldsResponse , error ) {
244
+
243
245
qsb := util .NewQueryStringBuilder ()
244
246
qsb .SetString ("query" , queryStr )
245
- qsb .SetInt ("field_limit " , int64 (fieldLimit ))
247
+ qsb .SetInt ("limit " , int64 (limit ))
246
248
qsb .SetInt ("line_limit" , int64 (lineLimit ))
247
249
qsb .SetInt ("start" , start .UnixNano ())
248
250
qsb .SetInt ("end" , end .UnixNano ())
@@ -251,7 +253,12 @@ func (c *DefaultClient) GetDetectedFields(
251
253
var err error
252
254
var r loghttp.DetectedFieldsResponse
253
255
254
- if err = c .doRequest (detectedFieldsPath , qsb .Encode (), quiet , & r ); err != nil {
256
+ path := detectedFieldsPath
257
+ if fieldName != "" {
258
+ path = fmt .Sprintf (detectedFieldValuesPath , url .PathEscape (fieldName ))
259
+ }
260
+
261
+ if err = c .doRequest (path , qsb .Encode (), quiet , & r ); err != nil {
255
262
return nil , err
256
263
}
257
264
0 commit comments