{"record":{"id":"77defef3677b7faf","repo":"thanos-io/thanos","slug":"applying-config-to-remote-storage","errorCode":null,"errorMessage":"applying config to remote storage","messagePattern":"applying config to remote storage","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":499,"sourceCode":"\t\t\tRemoteWriteConfigs []*config.RemoteWriteConfig `yaml:\"remote_write,omitempty\"`\n\t\t}\n\t\tif err := yaml.Unmarshal(rwCfgYAML, &rwCfg); err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to parse remote write config %v\", string(rwCfgYAML))\n\t\t}\n\n\t\tslogger := logutil.GoKitLogToSlog(logger)\n\t\t// flushDeadline is set to 1m, but it is for metadata watcher only so not used here.\n\t\t// TODO: add type and unit labels support?\n\t\tremoteStore := remote.NewStorage(slogger, reg, func() (int64, error) {\n\t\t\treturn 0, nil\n\t\t}, conf.dataDir, 1*time.Minute, &readyScrapeManager{}, false)\n\t\tif err := remoteStore.ApplyConfig(&config.Config{\n\t\t\tGlobalConfig: config.GlobalConfig{\n\t\t\t\tExternalLabels: labelsTSDBToProm(conf.lset),\n\t\t\t},\n\t\t\tRemoteWriteConfigs: rwCfg.RemoteWriteConfigs,\n\t\t}); err != nil {\n\t\t\treturn errors.Wrap(err, \"applying config to remote storage\")\n\t\t}\n\n\t\tagentDB, err = agent.Open(slogger, reg, remoteStore, conf.dataDir, agentOpts)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"start remote write agent db\")\n\t\t}\n\t\t// We need to call SetWriteNotified() so that agendDB gets notified about every write.\n\t\t// Without it we fallback to polling, which pulls new samples to write every 15s.\n\t\t// If we don't call SetWriteNotified() we'll have up to 15s lag between rule evaluation\n\t\t// and samples being sent over via remote_write.\n\t\tagentDB.SetWriteNotified(remoteStore)\n\t\tfanoutStore := storage.NewFanout(slogger, agentDB, remoteStore)\n\t\tappendable = fanoutStore\n\t\t// Use a separate queryable to restore the ALERTS firing states.\n\t\t// We cannot use remoteStore directly because it uses remote read for\n\t\t// query. However, remote read is not implemented in Thanos Receiver.\n\t\tqueryable = thanosrules.NewPromClientsQueryable(logger, queryClients, promClients, conf.query.httpMethod, conf.query.step, conf.ignoredLabelNames)\n\t} else {","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L481-L517","documentation":"This error wraps a failure from remoteStore.ApplyConfig when pushing the parsed remote write configs plus external labels into the remote storage WAL/queue manager. runRule calls it right after parsing the YAML. ApplyConfig rejects configs that Prometheus's remote write implementation considers invalid.","triggerScenarios":"remoteStore.ApplyConfig(&config.Config{...}) returns an error — e.g. duplicate remote_write queue names, invalid url in a remote_write config, or zero/misconfigured configs at the storage layer.","commonSituations":"Two remote_write entries with the same name, an invalid or unreachable url scheme, or external labels conflicting with what ApplyConfig validates.","solutions":["Ensure each remote_write entry has a unique `name` if more than one is configured.","Validate the remote_write url (scheme + host) is well-formed and reachable.","Compare against a working prometheus.yml remote_write section using promtool.","Read the wrapped error for the specific config index/field ApplyConfig rejected."],"exampleFix":"// before\nremote_write:\n  - url: http://r1/api/v1/receive\n    name: rw\n  - url: http://r2/api/v1/receive\n    name: rw   # duplicate\n// after\nremote_write:\n  - url: http://r1/api/v1/receive\n    name: rw-1\n  - url: http://r2/api/v1/receive\n    name: rw-2","handlingStrategy":"try-catch","validationCode":"names := map[string]bool{}\nfor _, c := range rwCfg.RemoteWriteConfigs {\n    if c.Name != \"\" {\n        if names[c.Name] {\n            return fmt.Errorf(\"duplicate remote_write name %q\", c.Name)\n        }\n        names[c.Name] = true\n    }\n    if _, err := url.Parse(c.URLConfig.URL.String()); err != nil {\n        return fmt.Errorf(\"bad remote_write url: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := remoteStore.ApplyConfig(cfg); err != nil {\n    logger.Error(\"remote write ApplyConfig rejected config\", \"err\", err)\n    return errors.Wrap(err, \"applying config to remote storage\")\n}","preventionTips":["Give every remote_write entry a unique name.","Test the exact YAML against a plain Prometheus instance first.","Check the wrapped ApplyConfig error for the rejected field."],"tags":["thanos","remote-write","config","startup"],"backgroundTag":"invalid-config-value","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"}