grafana/k6 · error

influxdb's ConcurrentWrites must be a positive number

Error message

influxdb's ConcurrentWrites must be a positive number

What it means

Thrown by the InfluxDB v1 output constructor when the resolved concurrentWrites setting is <= 0. The value sizes the semaphore channel (make(chan struct{}, conf.ConcurrentWrites.Int64)) used to bound concurrent write batches, so zero or negative values cannot initialize the output.

Source

Thrown at internal/output/influxdb/output.go:69

}

// New returns new influxdb output
func New(params output.Params) (output.Output, error) {
	return newOutput(params)
}

func newOutput(params output.Params) (*Output, error) {
	conf, err := GetConsolidatedConfig(params.JSONConfig, params.Environment, params.ConfigArgument)
	if err != nil {
		return nil, err
	}
	cl, err := MakeClient(conf)
	if err != nil {
		return nil, err
	}
	batchConf := MakeBatchConfig(conf)
	if conf.ConcurrentWrites.Int64 <= 0 {
		return nil, errors.New("influxdb's ConcurrentWrites must be a positive number")
	}
	fldKinds, err := MakeFieldKinds(conf)
	return &Output{
		params: params,
		logger: params.Logger.WithFields(logrus.Fields{
			"output": "InfluxDBv1",
		}),
		Client:      cl,
		Config:      conf,
		BatchConf:   batchConf,
		fieldKinds:  fldKinds,
		semaphoreCh: make(chan struct{}, conf.ConcurrentWrites.Int64),
		wg:          sync.WaitGroup{},
	}, err
}

func (o *Output) extractTagsToValues(tags map[string]string, values map[string]any) map[string]any {
	for tag, kind := range o.fieldKinds {

View on GitHub (pinned to 93accf6570)

Solutions

  1. Set concurrentWrites to a positive integer (default is 8 for typical setups): K6_INFLUXDB_CONCURRENT_WRITES=8
  2. Remove the concurrentWrites key from the -o influxdb=... argument string or the env var so the default applies
  3. Fix CI templates that default numeric env vars to 0

Example fix

# before
k6 run -o influxdb=http://localhost:8086/k6,concurrentWrites=0 script.js

# after
k6 run -o influxdb=http://localhost:8086/k6,concurrentWrites=8 script.js
Defensive patterns

Strategy: validation

Validate before calling

WRITES=${K6_INFLUXDB_CONCURRENT_WRITES:-8}
if ! [[ "$WRITES" =~ ^[1-9][0-9]*$ ]]; then echo "concurrentWrites must be >= 1, got '$WRITES'"; exit 1; fi
export K6_INFLUXDB_CONCURRENT_WRITES=$WRITES

Prevention

When it happens

Trigger: Setting K6_INFLUXDB_CONCURRENT_WRITES=0 or a negative number; passing --out influxdb=...,concurrentWrites=0; a JSON config for the output with "concurrentWrites": 0; any tooling that templates the env var to an empty/zero value.

Common situations: Copy-pasted output flag strings with a typo'd concurrentWrites=0; attempts to 'disable' concurrency by setting the knob to 0; container environments where an unset numeric env var resolves to 0 due to templating (e.g. K6_INFLUXDB_CONCURRENT_WRITES="${WRITES:-0}").

Related errors


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