{"record":{"id":"c10f5a9cfcc771bd","repo":"thanos-io/thanos","slug":"tsdb-statistics-not-implemented","errorCode":null,"errorMessage":"TSDB statistics not implemented","messagePattern":"TSDB statistics not implemented","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/status/status.go","lineNumber":145,"sourceCode":"\tTSDBStatistics(limit int, matchers []storepb.LabelMatcher) (map[string]tsdb.Stats, error)\n}\n\ntype TSDBStatisticsGetterFunc func(int, []storepb.LabelMatcher) (map[string]tsdb.Stats, error)\n\nfunc (f TSDBStatisticsGetterFunc) TSDBStatistics(limit int, matchers []storepb.LabelMatcher) (map[string]tsdb.Stats, error) {\n\treturn f(limit, matchers)\n}\n\n// NewServer creates a new server instance for the given component\n// and with the specified options.\nfunc NewServer(\n\tcomponent string,\n\toptions ...ServerOptionFunc,\n) *Server {\n\tsrv := &Server{\n\t\tcomponent: component,\n\t\ttsdbStatisticsGetter: TSDBStatisticsGetterFunc(func(int, []storepb.LabelMatcher) (map[string]tsdb.Stats, error) {\n\t\t\treturn nil, errors.New(\"TSDB statistics not implemented\")\n\t\t}),\n\t}\n\n\tfor _, o := range options {\n\t\to(srv)\n\t}\n\n\treturn srv\n}\n\n// ServerOptionFunc represents a functional option to configure the status server.\ntype ServerOptionFunc func(*Server)\n\nfunc WithTSDBStatisticsGetter(tsg TSDBStatisticsGetter) func(*Server) {\n\treturn func(s *Server) {\n\t\ts.tsdbStatisticsGetter = tsg\n\t}\n}","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/status/status.go#L127-L163","documentation":"status.NewServer in pkg/status/status.go:138 initializes the TSDBStatisticsGetter with a stub that always returns 'TSDB statistics not implemented'. Unless the caller supplies WithTSDBStatisticsGetter, any call to the Server's TSDBStatistics gRPC endpoint (pkg/status/status.go:166) immediately fails with this error.","triggerScenarios":"Constructing status.NewServer without the WithTSDBStatisticsGetter option, then a client invokes the TSDBStatistics RPC; or a component that intentionally does not support TSDB stats serves the endpoint.","commonSituations":"Embedding Thanos components (e.g. query frontend, rule evaluator) that have no TSDB and never registered a getter; forgetting to pass the option when wiring components; a client hitting the status endpoint of a component that does not own a TSDB.","solutions":["Pass the WithTSDBStatisticsGetter option when constructing the Server, backed by a real tsdb.DB.Stats implementation","If the component legitimately has no TSDB, stop clients from calling the TSDBStatistics endpoint on it and surface the error to the client as 'not supported'","Implement a custom TSDBStatisticsGetter that aggregates stats from the correct TSDB instances","Check component wiring/startup logs to confirm the getter option was applied before serving"],"exampleFix":"// before\nsrv := status.NewServer(\"query-frontend\")\n// after\nsrv := status.NewServer(\"query-frontend\", status.WithTSDBStatisticsGetter(getter))","handlingStrategy":"validation","validationCode":"// before serving, assert the getter was configured\nif !tsdbGetterConfigured(srv) {\n    logger.Warn(\"component does not support TSDB statistics; clients should not call this RPC\")\n}","typeGuard":null,"tryCatchPattern":"stats, err := statusClient.TSDBStatistics(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"TSDB statistics not implemented\") {\n    return nil, fmt.Errorf(\"component %s does not support TSDB statistics\", component)\n}","preventionTips":["Always pass WithTSDBStatisticsGetter when the component owns a TSDB","Document per-component support for the TSDBStatistics RPC","Gate client UI/API calls behind a component capability check","Add a startup-time assertion that the getter is non-stub when required"],"tags":["grpc","tsdb","configuration","thanos","status-api"],"backgroundTag":"method-not-implemented","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"}