thanos-io/thanos · error

get content of relabel configuration

Error message

get content of relabel configuration

What it means

The --receive.relabel-config (or default relabel config) flag is a PathOrContent; relabelCfg.Content() reads the YAML bytes from the file or inline content and this error wraps any failure to obtain that content. It fires before the YAML is even parsed, so the config is never applied and the caller gets an empty relabel config list.

Solutions

  1. Verify the path passed to --receive.relabel-config exists and is readable (cat the file as the running user).
  2. Check that any ${VAR} env vars referenced in the config are set in the environment.
  3. Confirm you are passing a file path or inline content, not a directory.
  4. If content is embedded in a ConfigMap/Secret, ensure the mount succeeded (kubectl describe pod, check mountPropagation).

Example fix

// before
thanos receive --receive.relabel-config=/etc/thanos/relabel.yaml  # file missing
// after
kubectl create configmap receive-relabel --from-file=relabel.yaml && mount it at /etc/thanos/relabel.yaml
Defensive patterns

Strategy: validation

Validate before calling

import os
def check_relabel_config(path_or_inline):
    if path_or_inline and os.path.exists(path_or_inline):
        if not os.path.isfile(path_or_inline):
            raise SystemExit("relabel config path is not a file")
        with open(path_or_inline) as f:
            data = f.read()
    else:
        data = os.path.expandvars(path_or_inline or "")
    if not data.strip():
        raise SystemExit("relabel config content is empty")
    return data

Type guard

def is_readable_file(p):
    try:
        return os.path.isfile(p) and os.access(p, os.R_OK)
    except (TypeError, ValueError):
        return False

Prevention

When it happens

Trigger: r.Content() errors because the path given to the extflag points at an unreadable/missing file, the inline content contains invalid ${VAR} expansion, or the content is empty when required.

Common situations: Typo in the relabel config file path; file mounted but not readable by the process user; unset env var referenced as ${VAR} in the config content; passing a directory instead of a file.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at cmd/thanos/receive.go:972

	lazyRetrievalMaxBufferedResponses int

	featureList *[]string

	headExpandedPostingsCacheSize            uint64
	compactedBlocksExpandedPostingsCacheSize uint64
	otlpEnableTargetInfo                     bool
	otlpResourceAttributes                   []string
}

type relabelCfg struct {
	*extflag.PathOrContent
}

func (r *relabelCfg) RelabelConfig(supportedActions map[relabel.Action]struct{}) ([]*relabel.Config, error) {
	relabelContentYaml, err := r.Content()
	if err != nil {
		return []*relabel.Config{}, errors.Wrap(err, "get content of relabel configuration")
	}
	return block.ParseRelabelConfig(relabelContentYaml, supportedActions)
}

func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
	rc.httpBindAddr, rc.httpGracePeriod, rc.httpTLSConfig = extkingpin.RegisterHTTPFlags(cmd)
	rc.grpcConfig.registerFlag(cmd)
	rc.storeRateLimits.RegisterFlags(cmd)

	cmd.Flag("remote-write.address", "Address to listen on for remote write requests.").
		Default("0.0.0.0:19291").StringVar(&rc.rwAddress)

	cmd.Flag("remote-write.server-tls-cert", "TLS Certificate for HTTP server, leave blank to disable TLS.").Default("").StringVar(&rc.rwServerCert)

	cmd.Flag("remote-write.server-tls-key", "TLS Key for the HTTP server, leave blank to disable TLS.").Default("").StringVar(&rc.rwServerKey)

	cmd.Flag("remote-write.server-tls-client-ca", "TLS CA to verify clients against. If no client CA is specified, there is no client verification on server side. (tls.NoClientCert)").Default("").StringVar(&rc.rwServerClientCA)

View on GitHub (pinned to 35b8b99117)