VictoriaMetrics/VictoriaMetrics · error

cannot get organizations

Error message

cannot get organizations: %w

What it means

Wrapped error from getOrganizations: the call to organization-manager /v1/organizations (including paginated follows) failed at the transport/HTTP level via getAPIResponse. The underlying cause is preserved with %w. This happens before any clouds are listed, so Yandex Cloud SD produces no targets.

Solutions

  1. Read the wrapped cause in the log for the actual HTTP status or network error
  2. Grant the service account organization-manager viewer permissions
  3. Verify the credentials configured for yandexcloud_sd are current
  4. Confirm outbound HTTPS access to the organization-manager service endpoint from the scrape host
Defensive patterns

Strategy: retry

Validate before calling

// verify org listing works before enabling sd
resp, err := http.Get(orgManagerURL + "/organization-manager/v1/organizations")
if err != nil || resp.StatusCode == 401 || resp.StatusCode == 403 { /* fix token/permissions */ }

Try / catch

orgs, err := cfg.getOrganizations()
if err != nil {
	log.Printf("yandexcloud sd organizations: %v", err)
	return cachedTargets, nil
}

Prevention

When it happens

Trigger: getAPIResponse(nextLink, cfg) errors on the organizations list or any nextPageToken page: invalid token, network failure, HTTP 4xx/5xx, or concurrency-limit rejection from the shared discovery client.

Common situations: Missing/invalid IAM credentials for the organization-manager API; service account lacking permission to list organizations; DNS or egress firewall issues; API-side throttling.

Related errors


AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03). Data as JSON: /api/errors/4069abb66aefecd6. Report an issue: GitHub.

Appendix: source

Thrown at lib/promscrape/discovery/yandexcloud/yandexcloud.go:216

}

type cloud struct {
	Name           string            `json:"name"`
	ID             string            `json:"id"`
	Labels         map[string]string `json:"labels"`
	OrganizationID string            `json:"organizationId"`
	Description    string            `json:"description"`
	CreatedAt      time.Time         `json:"createdAt"`
}

func (cfg *apiConfig) getOrganizations() ([]organization, error) {
	orgsURL := cfg.serviceEndpoints["organization-manager"] + "/organization-manager/v1/organizations"
	var orgs []organization
	nextLink := orgsURL
	for {
		data, err := getAPIResponse(nextLink, cfg)
		if err != nil {
			return nil, fmt.Errorf("cannot get organizations: %w", err)
		}
		var op organizationsPage
		if err := json.Unmarshal(data, &op); err != nil {
			return nil, fmt.Errorf("cannot parse organizations response from %q: %w; response body: %s", nextLink, err, data)
		}
		orgs = append(orgs, op.Organizations...)
		if len(op.NextPageToken) == 0 {
			return orgs, nil
		}
		nextLink = orgsURL + "&pageToken=" + url.QueryEscape(op.NextPageToken)
	}
}

// See https://cloud.yandex.com/en-ru/docs/organization/api-ref/Organization/list
type organizationsPage struct {
	Organizations []organization `json:"organizations"`
	NextPageToken string         `json:"nextPageToken"`
}

View on GitHub (pinned to 5079fb58f1)