grafana/k6 · error

gRPC exporter endpoint is required

Error message

gRPC exporter endpoint is required

What it means

When the OTel exporter protocol is grpc (the default), the output requires a gRPC endpoint. k6 defaults it to localhost:4317, so the check only fails when the default has been overridden with an empty value — K6_OTEL_GRPC_EXPORTER_ENDPOINT set to an empty string (or "grpcExporterEndpoint": "" in the JSON output config) — leaving nothing to dial.

Solutions

  1. Set a host:port value, e.g. export K6_OTEL_GRPC_EXPORTER_ENDPOINT=otel-collector:4317 (no scheme, no path)
  2. Remove the empty variable so the localhost:4317 default applies
  3. If your collector only serves HTTP (4318), switch protocol instead: K6_OTEL_EXPORTER_PROTOCOL=http/protobuf and configure the HTTP endpoint

Example fix

# before
export K6_OTEL_GRPC_EXPORTER_ENDPOINT=
k6 run -o opentelemetry script.js
# after
export K6_OTEL_GRPC_EXPORTER_ENDPOINT=otel-collector:4317
k6 run -o opentelemetry script.js
Defensive patterns

Strategy: validation

Validate before calling

// Shell
if [ "${K6_OTEL_EXPORTER_PROTOCOL:-grpc}" = "grpc" ] && [ -z "${K6_OTEL_GRPC_EXPORTER_ENDPOINT:-}" ]; then
  unset K6_OTEL_GRPC_EXPORTER_ENDPOINT   # restore localhost:4317 default
fi

Prevention

When it happens

Trigger: export K6_OTEL_GRPC_EXPORTER_ENDPOINT= (defined but empty) while protocol is grpc (default); a config JSON that blanks the gRPC endpoint; CI templates exporting the variable without a value for this collector.

Common situations: Empty-string overrides from CI matrices; configs written for an HTTP collector that blank out the gRPC endpoint instead of switching protocol; stale env files after moving collectors.

Related errors


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/7facced162f2df86. Report an issue: GitHub.

Appendix: source

Thrown at internal/output/opentelemetry/config.go:236

		return err
	}
	return nil
}

func (cfg Config) validateExporterProtocol() error {
	if cfg.ExporterProtocol.String != "" {
		if cfg.ExporterProtocol.String != grpcExporterProtocol && cfg.ExporterProtocol.String != httpExporterProtocol {
			return fmt.Errorf(
				"unsupported exporter protocol %q, only %q and %q are supported",
				cfg.ExporterProtocol.String,
				grpcExporterProtocol,
				httpExporterProtocol,
			)
		}
		switch cfg.ExporterProtocol.String {
		case grpcExporterProtocol:
			if cfg.GRPCExporterEndpoint.String == "" {
				return errors.New("gRPC exporter endpoint is required")
			}
		case httpExporterProtocol:
			endpoint := cfg.HTTPExporterEndpoint.String
			if endpoint == "" {
				return errors.New("HTTP exporter endpoint is required")
			}

			if strings.HasPrefix(endpoint, "http://") ||
				strings.HasPrefix(endpoint, "https://") {
				return errors.New("HTTP exporter endpoint must only be host and port, no scheme")
			}
		}
	}
	return nil
}

// String returns a string representation of the config
func (cfg Config) String() string {

View on GitHub (pinned to 01ffac6f24)