thanos-io/thanos · error

getting http client config

Error message

getting http client config

What it means

The sidecar's Setup reads the Prometheus HTTP client configuration content via conf.prometheus.httpClient.Content() (a flagext-style value holding the inline YAML/JSON for --prometheus.http-client-config style settings). If reading/obtaining that content fails, startup aborts with "getting http client config". This usually means the registered config flag value itself is unreadable or empty when content is required.

Solutions

  1. Check the wrapped error: it states why the config value could not be read (unset flag vs. invalid content).
  2. Supply a valid inline YAML/JSON http client config value for the Prometheus client flag if one is required.
  3. If no custom client config is needed, ensure the default (empty) config is accepted — avoid passing an empty string where content is mandatory.
  4. Verify the flag is registered and parsed before Setup runs (correct Kingpin registration in custom builds).

Example fix

// before
conf.prometheus.httpClient = nil // flag never registered/set
// after
registerHTTPClientFlags(cmd, &conf.prometheus.httpClient)
// and pass e.g.:
//   --prometheus.http-client-config='{"tls_config": {"ca_file": "/certs/ca.pem"}}'
Defensive patterns

Strategy: validation

Validate before calling

if conf.prometheus.httpClient == nil {
    return errors.New("prometheus http client config flag not set/registered")
}
if _, err := conf.prometheus.httpClient.Content(); err != nil {
    return fmt.Errorf("http client config unreadable: %w", err)
}

Type guard

null

Try / catch

httpConfContentYaml, err := conf.prometheus.httpClient.Content()
if err != nil {
    return fmt.Errorf("getting http client config: %w", err)
}

Prevention

When it happens

Trigger: The http client config flag (conf.prometheus.httpClient) was not set, is empty when content is required, or its Content() accessor fails because the registered value failed Kingpin parsing, so httpClient.Content() returns an error at cmd/thanos/sidecar.go:74.

Common situations: Omitting the HTTP client config flag while the deployment requires TLS/auth to reach Prometheus; passing a file path where inline content is expected (or vice versa); flag registration order issues when embedding the sidecar in custom builds.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


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

Appendix: source

Thrown at cmd/thanos/sidecar.go:75

	"github.com/thanos-io/thanos/pkg/targets"
	"github.com/thanos-io/thanos/pkg/tls"
)

func registerSidecar(app *extkingpin.App) {
	cmd := app.Command(component.Sidecar.String(), "Sidecar for Prometheus server.")
	conf := &sidecarConfig{}
	conf.registerFlag(cmd)
	cmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ <-chan struct{}, _ bool) error {

		grpcLogOpts, logFilterMethods, err := logging.ParsegRPCOptions(conf.reqLogConfig)

		if err != nil {
			return errors.Wrap(err, "error while parsing config for request logging")
		}

		httpConfContentYaml, err := conf.prometheus.httpClient.Content()
		if err != nil {
			return errors.Wrap(err, "getting http client config")
		}
		httpClientConfig, err := clientconfig.NewHTTPClientConfigFromYAML(httpConfContentYaml)
		if err != nil {
			return errors.Wrap(err, "parsing http config YAML")
		}

		httpClient, err := clientconfig.NewHTTPClient(*httpClientConfig, "thanos-sidecar")
		if err != nil {
			return errors.Wrap(err, "Improper http client config")
		}

		opts := reloader.Options{
			HTTPClient:    *httpClient,
			CfgFile:       conf.reloader.confFile,
			CfgOutputFile: conf.reloader.envVarConfFile,
			WatchedDirs:   conf.reloader.ruleDirectories,
			WatchInterval: conf.reloader.watchInterval,
			RetryInterval: conf.reloader.retryInterval,

View on GitHub (pinned to 35b8b99117)