{"record":{"id":"886615a846fb4f17","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-get-api-config-for-kuma-sd-w","errorCode":null,"errorMessage":"cannot get API config for kuma_sd: %w","messagePattern":"cannot get API config for kuma_sd: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/promscrape/discovery/kuma/kuma.go","lineNumber":40,"sourceCode":"\tServer   string `yaml:\"server\"`\n\tClientID string `yaml:\"client_id,omitempty\"`\n\n\tHTTPClientConfig  promauth.HTTPClientConfig  `yaml:\",inline\"`\n\tProxyURL          *proxy.URL                 `yaml:\"proxy_url,omitempty\"`\n\tProxyClientConfig promauth.ProxyClientConfig `yaml:\",inline\"`\n\n\t// fetch_timeout isn't used, so it isn't defined.\n\t// FetchTimeout time.Duration `yaml:\"fetch_timeout,omitempty\"`\n\n\t// refresh_interval is obtained from `-promscrape.kumaSDCheckInterval` command-line option.\n\t// RefreshInterval time.Duration `yaml:\"refresh_interval,omitempty\"`\n}\n\n// GetLabels returns kuma service discovery labels according to sdc.\nfunc (sdc *SDConfig) GetLabels(baseDir string) ([]*promutil.Labels, error) {\n\tcfg, err := getAPIConfig(sdc, baseDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot get API config for kuma_sd: %w\", err)\n\t}\n\tpLabels := cfg.labels.Load()\n\treturn *pLabels, nil\n}\n\n// MustStop stops further usage for sdc.\nfunc (sdc *SDConfig) MustStop() {\n\tv := configMap.Delete(sdc)\n\tif v != nil {\n\t\t// v can be nil if GetLabels wasn't called yet.\n\t\tcfg := v.(*apiConfig)\n\t\tcfg.mustStop()\n\t}\n}\n","sourceCodeStart":22,"sourceCodeEnd":55,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/promscrape/discovery/kuma/kuma.go#L22-L55","documentation":"SDConfig.GetLabels resolves the shared kuma_sd apiConfig via getAPIConfig -> newAPIConfig. Since the initial targets fetch happens synchronously inside newAPIConfig, any configuration error (bad server URL, invalid auth config, HTTP client creation failure) or initial discovery failure is wrapped here. The scrape config referencing this kuma_sd_config is rejected and target discovery for that job does not start.","triggerScenarios":"GetLabels is called when a scrape config with kuma_sd_configs is loaded. getAPIConfig -> newAPIConfig fails: getAPIServerPath rejects an empty/invalid server URL; HTTPClientConfig.NewConfig or ProxyClientConfig.NewConfig fails (missing cert files, bad basicauth); discoveryutil.NewClient fails; or the initial cfg.updateTargetsLabels fails (network unreachable, parse error) causing 'cannot discover Kuma targets'.","commonSituations":"Kuma section omitted 'server' entirely; typo in server URL; referenced tls_config cert files don't exist at startup (paths relative to config baseDir); Kuma control plane unreachable when VM/vmagent boots, so startup fails instead of retrying later.","solutions":["Read the wrapped cause (%w) below this message in the log to identify the failing sub-step (server parse, auth config, client creation, or initial fetch).","Ensure kuma_sd_config has a valid server URL, e.g. 'http://kuma-cp.kuma-system.svc:5678'.","Verify all files referenced by http_client_config (ca, cert, key, bearer_token_file) exist and are readable before starting VictoriaMetrics.","Make the Kuma control plane reachable before starting VictoriaMetrics, since the initial discovery fetch is synchronous and aborts config load on failure.","Validate the scrape config with the -promscrape.config check mode before restarting."],"exampleFix":"// before\nkuma_sd_configs:\n  - server: ''   # empty server -> 'cannot parse server' -> wrapped here\n// after\nkuma_sd_configs:\n  - server: 'http://kuma-cp.kuma-system.svc:5678'","handlingStrategy":"validation","validationCode":"# Validate the scrape config before restart:\n/victoria-metrics -promscrape.config=/etc/vm/promscrape.yml -promscrape.config.dryRun\n# Ensure the kuma_sd_config has a non-empty, reachable server:\ncurl -sf http://kuma-cp.kuma-system.svc:5678/v3/discovery:monitoringassignments -o /dev/null && echo OK","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set server explicitly in kuma_sd_configs; never leave it empty","Run config dry-run/check in CI before deploying scrape config changes","Use fully qualified Kubernetes service DNS (kuma-cp.kuma-system.svc) rather than bare names","Start the Kuma control plane before VictoriaMetrics, since the initial discovery fetch is synchronous","Check referenced http_client_config files exist before startup"],"tags":["configuration","service-discovery","kuma","promscrape","startup"],"backgroundTag":"invalid-scrape-config","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}