VictoriaMetrics/VictoriaMetrics · error
cannot query %q: %w
Error message
cannot query %q: %w
What it means
After validating api_endpoint, getServiceEndpoints performs GET <api_endpoint>/endpoints to fetch the map of Yandex Cloud service endpoints. This error wraps the transport failure of that GET (DNS, connect, TLS, timeout). The full endpointsURL is included so you can test it directly.
Source
Thrown at lib/promscrape/discovery/yandexcloud/api.go:263
// getServiceEndpoints returns services endpoints map
//
// See https://cloud.yandex.com/en-ru/docs/api-design-guide/concepts/endpoints
func (cfg *apiConfig) getServiceEndpoints(apiEndpoint string) (map[string]string, error) {
apiEndpointURL, err := url.Parse(apiEndpoint)
if err != nil {
return nil, fmt.Errorf("cannot parse api_endpoint %q: %w", apiEndpoint, err)
}
scheme := apiEndpointURL.Scheme
if scheme == "" {
return nil, fmt.Errorf("missing scheme in api_endpoint %q", apiEndpoint)
}
if apiEndpointURL.Host == "" {
return nil, fmt.Errorf("missing host in api_endpoint %q", apiEndpoint)
}
endpointsURL := apiEndpoint + "/endpoints"
resp, err := cfg.client.Get(endpointsURL)
if err != nil {
return nil, fmt.Errorf("cannot query %q: %w", endpointsURL, err)
}
data, err := readResponseBody(resp, endpointsURL)
if err != nil {
return nil, err
}
var eps endpoints
if err := json.Unmarshal(data, &eps); err != nil {
return nil, fmt.Errorf("cannot parse API endpoints list: %w; data=%s", err, data)
}
m := make(map[string]string, len(eps.Endpoints))
for _, endpoint := range eps.Endpoints {
m[endpoint.ID] = scheme + "://" + endpoint.Address
}
return m, nil
}
type endpoints struct {
Endpoints []endpoint `json:"endpoints"`View on GitHub (pinned to 5079fb58f1)
Solutions
- Fix the root cause shown by the wrapped error (DNS/TLS/timeout) after inspecting it
- Verify reachability: curl https://api.cloud.yandex.net/endpoints from the VictoriaMetrics host
- Open egress (firewall/proxy) to the Yandex API endpoint on 443
- Correct the api_endpoint if it points to a nonexistent host
Example fix
// before: firewalled host
yandexcloud_sd_configs: [{ api_endpoint: "https://api-unreachable.example.net" }]
// after
yandexcloud_sd_configs: [{ api_endpoint: "https://api.cloud.yandex.net" }] Defensive patterns
Strategy: retry
Validate before calling
endpointsURL := strings.TrimRight(apiEndpoint, "/") + "/endpoints"
resp, err := http.Get(endpointsURL)
if err != nil {
return fmt.Errorf("endpoints URL unreachable from this host: %w", err)
}
resp.Body.Close() Try / catch
eps, err := cfg.getServiceEndpoints(apiEndpoint)
if err != nil {
if isTransientNetErr(err) {
return getServiceEndpointsWithBackoff(cfg, apiEndpoint) // bounded retries
}
return fmt.Errorf("cannot reach Yandex /endpoints; check DNS and egress: %w", err)
} Prevention
- Confirm egress on 443 to the Yandex API host from the scraper machine
- Test with curl <api_endpoint>/endpoints before enabling discovery
- Fix container/pod DNS configuration if lookups fail
- Alert on repeated /endpoints fetch failures during config reloads
When it happens
Trigger: cfg.client.Get(endpointsURL) fails: api host unreachable, DNS resolution failure, TLS error, firewall egress block, or request timeout while fetching /endpoints.
Common situations: Air-gapped or firewalled clusters without egress to api.cloud.yandex.net; wrong custom api_endpoint host; DNS misconfiguration in containers; transient network outages during scrape-config reload.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- failed to lookupIPAddr for host: %q: %w
- failed to LookupSRV records for host: %q: %w
- cannot query yandex cloud api url %s: %w
- cannot get clouds: %w
- cannot get organizations: %w
AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03).
Data as JSON: /api/errors/540b153b78d946ad.
Report an issue: GitHub.