{"record":{"id":"0c65e46281025447","repo":"thanos-io/thanos","slug":"metric-label-values","errorCode":null,"errorMessage":"metric label values","messagePattern":"metric label values","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/index.go","lineNumber":253,"sourceCode":"\t\tchks []chunks.Meta\n\n\t\tseriesLifeDuration                          = newMinMaxSumInt64()\n\t\tseriesLifeDurationWithoutSingleSampleSeries = newMinMaxSumInt64()\n\t\tseriesChunks                                = newMinMaxSumInt64()\n\t\tchunkDuration                               = newMinMaxSumInt64()\n\t\tchunkSize                                   = newMinMaxSumInt64()\n\t\tseriesSize                                  = newMinMaxSumInt64()\n\t)\n\n\tlnames, err := r.LabelNames(ctx)\n\tif err != nil {\n\t\treturn stats, errors.Wrap(err, \"label names\")\n\t}\n\tstats.LabelNamesCount = int64(len(lnames))\n\n\tlvals, err := r.LabelValues(ctx, \"__name__\", nil)\n\tif err != nil {\n\t\treturn stats, errors.Wrap(err, \"metric label values\")\n\t}\n\tstats.MetricLabelValuesCount = int64(len(lvals))\n\n\t// As of version two all series entries are 16 byte padded. All references\n\t// we get have to account for that to get the correct offset.\n\toffsetMultiplier := 1\n\tversion := r.Version()\n\tif version >= 2 {\n\t\toffsetMultiplier = 16\n\t}\n\n\t// Per series.\n\tvar prevId storage.SeriesRef\n\tfor p.Next() {\n\t\tprevLset.CopyFrom(lset)\n\n\t\tid := p.At()\n\t\tif prevId != 0 {","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/index.go#L235-L271","documentation":"GatherIndexHealthStats calls r.LabelValues(ctx, \"__name__\", nil) to count metric label values. Failure of that postings lookup is wrapped as \"metric label values\". Like the label-names failure, it points at a damaged or unreadable index postings/symbols table for the __name__ label.","triggerScenarios":"GatherIndexHealthStats/VerifyIndex on a block with a truncated index where the __name__ label values postings cannot be decoded, or ctx cancellation mid-read.","commonSituations":"Incomplete multi-part uploads to object storage, corrupted block downloads (e.g. interrupted prom TSDB block sync), degraded disks.","solutions":["Restore/re-download the block from object storage","Verify the block with VerifyIndex to confirm index corruption","Bump the verification context deadline","Remove the unreadable block so it can be re-synced"],"exampleFix":"// before\nstats, err := block.GatherIndexHealthStats(ctx, bdir) // metric label values: unexpected EOF\n// after\nf, err := os.Open(filepath.Join(bdir, \"index\"))\nif err != nil { return err }\nfi, _ := f.Stat()\n_ = f.Close()\nif fi.Size() < minValidIndexSize { return fmt.Errorf(\"index truncated: %d bytes\", fi.Size()) }\nstats, err := block.GatherIndexHealthStats(ctx, bdir)","handlingStrategy":"validation","validationCode":"func blockLooksComplete(bdir string) bool {\n    _, err := os.Stat(filepath.Join(bdir, \"meta.json\"))\n    if err != nil { return false }\n    fi, err := os.Stat(filepath.Join(bdir, \"index\"))\n    return err == nil && fi.Size() > 0\n}","typeGuard":null,"tryCatchPattern":"stats, err := block.GatherIndexHealthStats(ctx, bdir)\nif err != nil && strings.Contains(err.Error(), \"metric label values\") {\n    return fmt.Errorf(\"index postings for __name__ unreadable in %s: %w\", bdir, err)\n}","preventionTips":["Verify multi-part object uploads completed before importing blocks","Use Thanos sync tooling rather than manual copies for block movement","Monitor disks for bit-rot with periodic scrubbing","Set generous verification timeouts"],"tags":["corruption","index","labels"],"backgroundTag":"file-read-failed","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"}