grafana/k6 · error

HTTP exporter endpoint must only be host and port, no scheme

Error message

HTTP exporter endpoint must only be host and port, no scheme

What it means

The OTel HTTP exporter endpoint option takes only host:port — the OTel SDK adds the scheme based on the insecure flag and uses the separately-configured URL path. k6 therefore rejects endpoints that start with http:// or https:// with this error, so the scheme does not silently conflict with K6_OTEL_HTTP_EXPORTER_INSECURE / TLS settings.

Solutions

  1. Strip the scheme: K6_OTEL_HTTP_EXPORTER_ENDPOINT=otel-collector:4318
  2. Set the path separately via K6_OTEL_HTTP_EXPORTER_URL_PATH if you need a non-default path (default is /v1/metrics)
  3. For plaintext, set K6_OTEL_HTTP_EXPORTER_INSECURE=true instead of relying on http://

Example fix

# before
export K6_OTEL_EXPORTER_PROTOCOL=http/protobuf
export K6_OTEL_HTTP_EXPORTER_ENDPOINT=http://otel-collector:4318
# after
export K6_OTEL_EXPORTER_PROTOCOL=http/protobuf
export K6_OTEL_HTTP_EXPORTER_ENDPOINT=otel-collector:4318
Defensive patterns

Strategy: validation

Validate before calling

// Shell: normalize a full URL into endpoint + path
raw="${K6_OTEL_HTTP_EXPORTER_ENDPOINT:-}"
case "$raw" in
  https://*) host=${raw#https://}; scheme_off=1 ;;
  http://*)  host=${raw#http://} ;;
  *) host=$raw ;;
esac
endpoint=${host%%/*}; path=/${raw#*/}; [ "$path" = "/$raw" ] && unset path
export K6_OTEL_HTTP_EXPORTER_ENDPOINT=$endpoint
[ -n "${path:-}" ] && export K6_OTEL_HTTP_EXPORTER_URL_PATH=$path

Type guard

function isBareHostPort(ep) {
  return /^[^\/]+:\d+$/.test(ep);
}

Prevention

When it happens

Trigger: K6_OTEL_HTTP_EXPORTER_ENDPOINT=http://otel-collector:4318 (natural-looking but wrong); same with https://; configs ported from OTEL_EXPORTER_OTLP_ENDPOINT, which does allow full URLs.

Common situations: Copy-pasting the standard OTel env var value into k6's endpoint variable; assuming k6 accepts the same URL forms as the OTel SDK/collector.

Related errors


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

Appendix: source

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

				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"
		if !cfg.HTTPExporterInsecure.Bool {
			endpoint += "s"
		}
		endpoint += "://" + cfg.HTTPExporterEndpoint.String + cfg.HTTPExporterURLPath.String
	case grpcExporterProtocol:

View on GitHub (pinned to 01ffac6f24)