{"record":{"id":"667c18c2243c6f6b","repo":"jaegertracing/jaeger","slug":"failed-to-find-latest-index","errorCode":null,"errorMessage":"failed to find latest index","messagePattern":"failed to find latest index","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/elasticsearch/samplingstore/storage.go","lineNumber":177,"sourceCode":"\t\t\tTimestamp:           ts,\n\t\t\tProbabilitiesAndQPS: pandqps,\n\t\t},\n\t}})\n}\n\nfunc (s *SamplingStore) getLatestIndex(ctx context.Context) (string, error) {\n\tnow := s.now().UTC()\n\tcandidates := s.rotation.ReadTargets(now.Add(-s.lookback), now)\n\tfor _, idx := range candidates {\n\t\texists, err := s.indexClient.IndexExists(ctx, idx)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to check index existence: %w\", err)\n\t\t}\n\t\tif exists {\n\t\t\treturn idx, nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"failed to find latest index\")\n}\n\nfunc buildTSQuery(start, end time.Time) query.Query {\n\treturn query.NewRangeQuery(\"timestamp\").Gte(start).Lte(end)\n}\n","sourceCodeStart":159,"sourceCodeEnd":183,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/elasticsearch/samplingstore/storage.go#L159-L183","documentation":"In internal/storage/v1/elasticsearch/samplingstore/storage.go, getLatestProbabilities calls getLatestIndex, which walks candidate index names (checking each with an existence check) and returns errors.New(\"failed to find latest index\") when none of the candidate indices exists. This typically means the adaptive-sampling indices were never written by a jaeger-collector/remote-storage with adaptive sampling enabled, or the index naming/date pattern does not match what was actually created.","triggerScenarios":"GetLatestProbabilities (via getLatestIndex) runs when no index matching the jaeger-sampling index prefix/date pattern exists in the ES cluster — the existence check for every candidate index returned false.","commonSituations":"Fresh Elasticsearch/OpenSearch cluster with no collector writing sampling data yet; sampling index prefix/date format mismatch between writer and reader (e.g. changed index prefix in config, ILM rollover/retention deleting old indices); clock skew or wrong timezone shifting the candidate date list away from existing indices.","solutions":["Verify sampling indices exist: list indices matching the jaeger sampling prefix (e.g. jaeger-sampling-*) in the cluster and confirm data was written.","Ensure a collector/remote-storage with adaptive sampling enabled is writing sampling data; without a writer the index never appears.","Check that the storage index prefix/date-layout configuration matches between the component that writes and the one reading (jaeger.index-prefix, date format).","Confirm cluster clocks/timezone are correct and retention policies (ILM) have not deleted the recent sampling indices.","Handle the error gracefully in the caller by falling back to default probabilities until the first index is published."],"exampleFix":"// before\nprobs, err := store.GetLatestProbabilities()\n// after\nprobs, err := store.GetLatestProbabilities()\nif errors.Is(err, ErrNoIndices) || strings.Contains(err.Error(), \"failed to find latest index\") {\n    probs = defaultProbabilities // fall back until collector publishes sampling data\n}","handlingStrategy":"fallback","validationCode":"// before querying: check indices exist\nexists, err := client.IndexExists(indexPrefix + \"-*\").Do(ctx)\nif err != nil || !exists {\n    return nil, errors.New(\"no sampling indices present; adaptive sampling writer not running?\")\n}","typeGuard":null,"tryCatchPattern":"probs, err := store.GetLatestProbabilities()\nif err != nil && strings.Contains(err.Error(), \"failed to find latest index\") {\n    probs = defaultProbabilities // serve defaults and retry later\n}","preventionTips":["Run a collector/remote-storage with adaptive sampling enabled so the index is populated before readers start.","Keep index prefix and date-format config identical across writer and reader components.","Monitor for sampling indices and alert when none exist within the expected window.","Verify retention/ILM policies do not delete recent sampling indices."],"tags":["elasticsearch","sampling","index-not-found","storage"],"backgroundTag":"index-not-found","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}