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

Thrown by Config.validateExporterProtocol() when the HTTP exporter endpoint starts with http:// or https://. The OTLP HTTP exporter option expects host[:port] and applies its own scheme/insecure logic (httpExporterInsecure), so an embedded scheme would produce a malformed URL and is rejected up front.

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 93accf6570)

Solutions

  1. Strip the scheme: K6_OTEL_HTTP_EXPORTER_ENDPOINT=collector.example.com:4318
  2. For plain HTTP to a local collector, keep the bare host:port and set K6_OTEL_HTTP_EXPORTER_INSECURE=true if TLS must not be attempted
  3. Update any config templates that store the full URL and derive the bare endpoint from it

Example fix

# before
export K6_OTEL_HTTP_EXPORTER_ENDPOINT=http://localhost:4318

# after
export K6_OTEL_HTTP_EXPORTER_ENDPOINT=localhost:4318
export K6_OTEL_HTTP_EXPORTER_INSECURE=true
Defensive patterns

Strategy: validation

Validate before calling

case "$K6_OTEL_HTTP_EXPORTER_ENDPOINT" in
  http://*|https://*) echo "endpoint must be host:port without scheme"; exit 1;;
esac

Prevention

When it happens

Trigger: Setting K6_OTEL_HTTP_EXPORTER_ENDPOINT=https://collector.example.com:4318 or http://localhost:4318 while exporterProtocol is http/protobuf; copying a full collector URL from documentation or a browser into the env var; JSON config with a fully-qualified URL in httpExporterEndpoint.

Common situations: Users pasting the collector's web URL; mixing conventions with Prometheus remote write (-o prometheus-rw) where URLs are expected; confusion after switching from OTLP/HTTP gateway examples that show scheme-prefixed URLs.

Related errors


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