thanos-io/thanos · warning

No StoreAPIs matched for this query

Error message

No StoreAPIs matched for this query

What it means

ErrorNoStoresMatched is a sentinel error returned by the proxy Store when, after filtering all discovered stores by external labels, time range, and matchers, no StoreAPI matches the query. Unlike the "no stores available" case, stores exist but none is eligible for this request. In ABORT mode it surfaces as an error; in partial-response mode it may just log and return empty.

Solutions

  1. Broaden the query time range to overlap the stores' minTime/maxTime
  2. Check matchers against the stores' external labels (Thanos Store flags --store-.* or query's --query.replica-label configuration)
  3. Log/store debug messages (already emitted at debug level) to see why each store was filtered out
  4. If the empty result is acceptable, ensure PartialResponseStrategy is ALLOW and handle the empty stream gracefully

Example fix

// before: filter excludes everything
storeMatchers := []string{"{cluster="wrong"}"}
// after: match the actual external labels
storeMatchers := []string{"{cluster="prod"}"}
Defensive patterns

Strategy: validation

Validate before calling

// before querying, ensure the time range overlaps store data and matchers target existing external labels
if queryEnd < storeMinTime || queryStart > storeMaxTime {
    return fmt.Errorf("time range %d-%d matches no store data", queryStart, queryEnd)
}

Try / catch

resp, err := queryClient.Series(ctx, req)
if status.Code(err) == codes.Unknown && strings.Contains(err.Error(), ErrorNoStoresMatched.Error()) {
    // widen time range or fix external-label matchers; or accept empty result
}

Prevention

When it happens

Trigger: Query matchers or time range exclude every store's external labels/min-time/max-time — e.g. querying a time window before any store's data, or matchers referencing labels/stores not part of the query tree (common in Thanos Query layering with replicated stores).

Common situations: Querying for a time range outside all data retention; wrong external-label values in the query (cluster/replica labels); ruler/receiver stores excluded via store matchers (--store-.* regex flags); dedup/replica label mismatch.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/bd4c96724979f18e. Report an issue: GitHub.

Appendix: source

Thrown at pkg/store/proxy.go:48

	"github.com/thanos-io/thanos/pkg/query/fanout"
	storecache "github.com/thanos-io/thanos/pkg/store/cache"
	"github.com/thanos-io/thanos/pkg/store/labelpb"
	"github.com/thanos-io/thanos/pkg/store/storepb"
	"github.com/thanos-io/thanos/pkg/strutil"
	"github.com/thanos-io/thanos/pkg/tenancy"
)

type ctxKey int

// UninitializedTSDBTime is the TSDB start time of an uninitialized TSDB instance.
const UninitializedTSDBTime = math.MaxInt64

// StoreMatcherKey is the context key for the store's allow list.
const StoreMatcherKey = ctxKey(0)

// ErrorNoStoresMatched is returned if the query does not match any data.
// This can happen with Query servers trees and external labels.
var ErrorNoStoresMatched = errors.New("No StoreAPIs matched for this query")

// ErrorNoStoresAvailable is returned if we have an empty list of stores.
// This happens either when we didn't yet complete any discovery
// or when all stores disappear suddenly.
var ErrorNoStoresAvailable = errors.New("No StoreAPIs available")

// Client holds meta information about a store.
type Client interface {
	// StoreClient to access the store.
	storepb.StoreClient

	// LabelSets that each apply to some data exposed by the backing store.
	LabelSets() []labels.Labels

	// TimeRange returns minimum and maximum time range of data in the store.
	TimeRange() (mint int64, maxt int64)

	// TSDBInfos returns metadata about each TSDB backed by the client.

View on GitHub (pinned to 35b8b99117)