{"record":{"id":"69279db1d424b9f9","repo":"thanos-io/thanos","slug":"results-truncated-due-to-limit","errorCode":null,"errorMessage":"results truncated due to limit","messagePattern":"results truncated due to limit","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/api/query/v1.go","lineNumber":1164,"sourceCode":"\t\tvals = make([]string, 0, len(labelValuesSet))\n\t\tfor val := range labelValuesSet {\n\t\t\tvals = append(vals, val)\n\t\t}\n\t\tsort.Strings(vals)\n\t} else {\n\t\tvals, warnings, err = q.LabelValues(ctx, name, hints)\n\t\tif err != nil {\n\t\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorExec, Err: err}, func() {}\n\t\t}\n\t}\n\n\tif vals == nil {\n\t\tvals = make([]string, 0)\n\t}\n\n\tif limit > 0 && len(vals) > limit {\n\t\tvals = vals[:limit]\n\t\twarnings = warnings.Add(errors.New(\"results truncated due to limit\"))\n\t}\n\n\treturn vals, warnings.AsErrors(), nil, func() {}\n}\n\nfunc (qapi *QueryAPI) series(r *http.Request) (any, []error, *api.ApiError, func()) {\n\tif err := r.ParseForm(); err != nil {\n\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorInternal, Err: errors.Wrap(err, \"parse form\")}, func() {}\n\t}\n\n\tif len(r.Form[MatcherParam]) == 0 {\n\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: errors.New(\"no match[] parameter provided\")}, func() {}\n\t}\n\n\tstart, end, err := parseMetadataTimeRange(r, qapi.defaultMetadataTimeRange)\n\tif err != nil {\n\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: err}, func() {}\n\t}","sourceCodeStart":1146,"sourceCodeEnd":1182,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/api/query/v1.go#L1146-L1182","documentation":"The labelValues endpoint truncates its result to the limit= parameter and adds a warning (not an error) \"results truncated due to limit\" when more values exist than the limit allows. The truncated list is still returned (HTTP 200) alongside warnings.AsErrors().","triggerScenarios":"GET /api/v1/label/<name>/values?limit=N where the label has more than N distinct values; default limits applied by clients/proxies.","commonSituations":"High-cardinality labels (pod names, trace IDs) with thousands of values; dashboards setting a small limit for performance.","solutions":["Increase the limit parameter (or remove it) to cover all values","Use the match[] parameter to narrow which series' label values are collected","Treat the warning as informational: page through or aggregate client-side"],"exampleFix":"// before\nGET /api/v1/label/pod/values?limit=10\n// after\nGET /api/v1/label/pod/values?limit=0  # or match[]=... to scope the query","handlingStrategy":"type-guard","validationCode":"// Nothing to pre-validate; inspect the response warnings field:\nif resp.Status == \"success\" && len(resp.Warnings) > 0 {\n    // results may be truncated; fetch with a higher limit or match[]\n}","typeGuard":null,"tryCatchPattern":"if slices.Contains(warnings, \"results truncated due to limit\") {\n    log.Warn(\"label values truncated; increasing limit\")\n    // re-issue request with larger limit\n}","preventionTips":["Always inspect resp.Warnings, not just resp.Data","Set generous or no limit when full enumerations are needed","Use match[] to bound cardinality instead of relying on truncation"],"tags":["http-api","labels","truncation"],"backgroundTag":"empty-result-set","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}