grafana/k6 · error

failed to ingest request metadatas batch: code=%s, msg=%s

Error message

failed to ingest request metadatas batch: code=%s, msg=%s

What it means

The gRPC BatchCreateRequestMetadatas RPC to the cloud insights ingester returned an error status (internal/cloudapi/insights/client.go:181-186); the message embeds the gRPC status code name and the server's message via status.Convert. This is the server/network side answering - the request was built and sent, but the ingester rejected it or the transport failed. The client's retry interceptor (with codes from RetryConfig) has already exhausted its attempts for retryable codes.

Source

Thrown at internal/cloudapi/insights/client.go:185

	if closed {
		return ErrClientClosed
	}

	if len(requestMetadatas) < 1 {
		return nil
	}

	req, err := newBatchCreateRequestMetadatasRequest(requestMetadatas)
	if err != nil {
		return fmt.Errorf("failed to create request from request metadatas: %w", err)
	}

	ctx, cancel := context.WithTimeout(ctx, c.cfg.Timeout)
	defer cancel()
	_, err = c.client.BatchCreateRequestMetadatas(ctx, req)
	if err != nil {
		st := status.Convert(err)
		return fmt.Errorf("failed to ingest request metadatas batch: code=%s, msg=%s", st.Code().String(), st.Message())
	}

	return nil
}

// Close closes the client.
func (c *Client) Close() error {
	c.connMu.Lock()
	defer c.connMu.Unlock()

	if c.conn == nil {
		return ErrClientClosed
	}

	conn := c.conn
	c.client = nil
	c.conn = nil

View on GitHub (pinned to 93accf6570)

Solutions

  1. Match the printed gRPC code: Unavailable/DeadlineExceeded point to network or timeout tuning; Unauthenticated/PermissionDenied to the run's token - re-provision the run
  2. For DeadlineExceeded, reduce batch sizes (fewer concurrent HTTP-heavy VUs) or raise the per-call timeout in the insights config
  3. For ResourceExhausted, lower load or spread request-metadata emission, and update k6 in case limits changed
  4. Check the Grafana Cloud status page for ingester incidents before debugging locally
Defensive patterns

Strategy: retry

Type guard

// Go: classify gRPC status codes to decide retry vs abort
func isRetryableGRPC(code codes.Code) bool {
    switch code {
    case codes.Unavailable, codes.DeadlineExceeded, codes.ResourceExhausted:
        return true
    }
    return false
}

Try / catch

err := client.IngestRequestMetadatasBatch(ctx, batch)
if err != nil {
    if strings.Contains(err.Error(), "failed to ingest request metadatas batch") {
        // message embeds code= and msg=; Unauthenticated/PermissionDenied need re-provisioning,
        // Unavailable/DeadlineExceeded are safe to retry with backoff
    }
}

Prevention

When it happens

Trigger: Unavailable (ingester down or unreachable mid-run); DeadlineExceeded (cfg.Timeout too short for the batch size); Unauthenticated/PermissionDenied (stale or wrong test-run token for the per-RPC credentials, client.go:293-301); InvalidArgument (malformed/oversized batch); ResourceExhausted (server-side limits).

Common situations: Slow links making per-call deadlines too tight for large batches; a long-running test whose scoped run token expired; an ingester incident; oversized bursts of HTTP request metadata from high-RPS scripts.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/43968205f8ef3800. Report an issue: GitHub.