{"record":{"id":"43968205f8ef3800","repo":"grafana/k6","slug":"failed-to-ingest-request-metadatas-batch-code-s","errorCode":null,"errorMessage":"failed to ingest request metadatas batch: code=%s, msg=%s","messagePattern":"failed to ingest request metadatas batch: code=(.+?), msg=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/insights/client.go","lineNumber":185,"sourceCode":"\tif closed {\n\t\treturn ErrClientClosed\n\t}\n\n\tif len(requestMetadatas) < 1 {\n\t\treturn nil\n\t}\n\n\treq, err := newBatchCreateRequestMetadatasRequest(requestMetadatas)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create request from request metadatas: %w\", err)\n\t}\n\n\tctx, cancel := context.WithTimeout(ctx, c.cfg.Timeout)\n\tdefer cancel()\n\t_, err = c.client.BatchCreateRequestMetadatas(ctx, req)\n\tif err != nil {\n\t\tst := status.Convert(err)\n\t\treturn fmt.Errorf(\"failed to ingest request metadatas batch: code=%s, msg=%s\", st.Code().String(), st.Message())\n\t}\n\n\treturn nil\n}\n\n// Close closes the client.\nfunc (c *Client) Close() error {\n\tc.connMu.Lock()\n\tdefer c.connMu.Unlock()\n\n\tif c.conn == nil {\n\t\treturn ErrClientClosed\n\t}\n\n\tconn := c.conn\n\tc.client = nil\n\tc.conn = nil\n","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/insights/client.go#L167-L203","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Match the printed gRPC code: Unavailable/DeadlineExceeded point to network or timeout tuning; Unauthenticated/PermissionDenied to the run's token - re-provision the run","For DeadlineExceeded, reduce batch sizes (fewer concurrent HTTP-heavy VUs) or raise the per-call timeout in the insights config","For ResourceExhausted, lower load or spread request-metadata emission, and update k6 in case limits changed","Check the Grafana Cloud status page for ingester incidents before debugging locally"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"// Go: classify gRPC status codes to decide retry vs abort\nfunc isRetryableGRPC(code codes.Code) bool {\n    switch code {\n    case codes.Unavailable, codes.DeadlineExceeded, codes.ResourceExhausted:\n        return true\n    }\n    return false\n}","tryCatchPattern":"err := client.IngestRequestMetadatasBatch(ctx, batch)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to ingest request metadatas batch\") {\n        // message embeds code= and msg=; Unauthenticated/PermissionDenied need re-provisioning,\n        // Unavailable/DeadlineExceeded are safe to retry with backoff\n    }\n}","preventionTips":["Configure RetryableStatusCodes to cover Unavailable and ResourceExhausted so transient ingester errors self-heal","Keep batches modest so per-call timeouts are not exceeded on slow links","Watch for Unauthenticated late in long runs - scoped run tokens expire; re-provision instead of retrying"],"tags":["cloud","grpc","insights","network","authentication"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}