grafana/k6 · error

couldn't parse argument %q as option

Error message

couldn't parse argument %q as option

What it means

parseArg splits the Prometheus remote-write config string on commas and requires each option to be key=value (SplitN with 2 parts). This fires when an option fragment lacks '=' (or is empty), meaning the user's remote-write output configuration string is malformed and k6 cannot start the output.

Source

Thrown at internal/output/prometheusrw/remotewrite/config.go:337

	return c, nil
}

// parseJSON parses the supplied JSON into a Config.
func parseJSON(data json.RawMessage) (Config, error) {
	var c Config
	err := json.Unmarshal(data, &c)
	return c, err
}

// parseArg parses the supplied string of arguments into a Config.
func parseArg(text string) (Config, error) {
	var c Config
	opts := strings.SplitSeq(text, ",")

	for opt := range opts {
		r := strings.SplitN(opt, "=", 2)
		if len(r) != 2 {
			return c, fmt.Errorf("couldn't parse argument %q as option", opt)
		}
		key, v := r[0], r[1]
		switch key {
		case "url":
			c.ServerURL = null.StringFrom(v)
		case "insecureSkipTLSVerify":
			if err := c.InsecureSkipTLSVerify.UnmarshalText([]byte(v)); err != nil {
				return c, fmt.Errorf("insecureSkipTLSVerify value must be true or false, not %q", v)
			}
		case "tlsMinVersion":
			c.TLSMinVersion = null.StringFrom(v)
		case "username":
			c.Username = null.StringFrom(v)
		case "password":
			c.Password = null.StringFrom(v)
		case "pushInterval":
			if err := c.PushInterval.UnmarshalText([]byte(v)); err != nil {
				return c, err

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Add '=' and a value to each option, e.g. --out prometheus-rw=url=http://prometheus:9090/api/v1/write,insecureSkipTLSVerify=true
  2. Remove stray comma-separated tokens that aren't options
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/output/prometheusrw/remotewrite/config.go:337 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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