grafana/k6 · error

HTTP exporter endpoint is required

Error message

HTTP exporter endpoint is required

What it means

When the OTel exporter protocol is http/protobuf, the output requires an HTTP endpoint (host:port). k6 defaults it to localhost:4318, so the check fails when the default has been overridden with an empty value — K6_OTEL_HTTP_EXPORTER_ENDPOINT set to empty (or "httpExporterEndpoint": "" in JSON config) while the protocol is http/protobuf.

Solutions

  1. Set a host:port value, e.g. export K6_OTEL_HTTP_EXPORTER_ENDPOINT=otel-collector:4318
  2. Remove the empty variable so the localhost:4318 default applies
  3. Remember the URL path is configured separately via K6_OTEL_HTTP_EXPORTER_URL_PATH (default /v1/metrics) — do not put the path in the endpoint

Example fix

# before
export K6_OTEL_EXPORTER_PROTOCOL=http/protobuf
export K6_OTEL_HTTP_EXPORTER_ENDPOINT=
k6 run -o opentelemetry script.js
# after
export K6_OTEL_EXPORTER_PROTOCOL=http/protobuf
export K6_OTEL_HTTP_EXPORTER_ENDPOINT=otel-collector:4318
k6 run -o opentelemetry script.js
Defensive patterns

Strategy: validation

Validate before calling

// Shell
if [ "${K6_OTEL_EXPORTER_PROTOCOL:-}" = "http/protobuf" ] && [ -z "${K6_OTEL_HTTP_EXPORTER_ENDPOINT:-}" ]; then
  unset K6_OTEL_HTTP_EXPORTER_ENDPOINT   # restore localhost:4318 default
fi

Prevention

When it happens

Trigger: export K6_OTEL_EXPORTER_PROTOCOL=http/protobuf together with K6_OTEL_HTTP_EXPORTER_ENDPOINT= (empty); a JSON output config that selects the HTTP protocol but blanks the endpoint; CI variables that exist but are unpopulated.

Common situations: Switching a pipeline from grpc to HTTP export and clearing the old-style endpoint; templated configs where the endpoint variable is provisioned per-environment and this one is missing.

Related errors


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

Appendix: source

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

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 {
	var endpoint string
	protocol := cfg.ExporterProtocol.String
	switch protocol {
	case httpExporterProtocol:
		endpoint = "http"

View on GitHub (pinned to 01ffac6f24)