grafana/k6 · error
influxdb's ConcurrentWrites must be a positive number
Error message
influxdb's ConcurrentWrites must be a positive number
What it means
The InfluxDB output validates that the configured concurrency for parallel metric writes is a positive integer before constructing the output. K6_INFLUXDB_CONCURRENT_WRITES (or the equivalent JSON/CLI config) of 0 or a negative number fails with this error, because the output sizes its semaphore channel from this value.
Solutions
- Set a positive integer, e.g. K6_INFLUXDB_CONCURRENT_WRITES=8 (the documented default)
- Unset the variable to fall back to the default
- Check for typos or empty values in wrapper scripts that export the variable
Example fix
# before export K6_INFLUXDB_CONCURRENT_WRITES=0 k6 run -o influxdb=http://localhost:8086/k6 script.js # after unset K6_INFLUXDB_CONCURRENT_WRITES # default applies k6 run -o influxdb=http://localhost:8086/k6 script.js
Defensive patterns
Strategy: validation
Validate before calling
// Shell
n="${K6_INFLUXDB_CONCURRENT_WRITES:-}"
if [ -n "$n" ] && ! [ "$n" -gt 0 ] 2>/dev/null; then
echo "K6_INFLUXDB_CONCURRENT_WRITES must be a positive integer" >&2; exit 1
fi Type guard
function isPositiveInt(v) {
return /^\d+$/.test(v) && parseInt(v, 10) > 0;
} Prevention
- Don't repurpose K6_INFLUXDB_CONCURRENT_WRITES=0 to disable anything — unset it instead
- Validate numeric env overrides once in a shared pre-run hook
- Document the default (8-ish concurrency) so nobody invents values
When it happens
Trigger: K6_INFLUXDB_CONCURRENT_WRITES=0 or a negative value in the environment; the corresponding -o influxdb=...,concurrentWrites=0 argument; empty-string values that parse to 0 in some wrappers.
Common situations: CI templates that define the variable but leave it empty/zero; attempts to 'disable' concurrency by setting 0; copy-pasted dashboards from old blog posts using invalid values.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- both K6_CLOUD_METRICS_PUSH_URL and K6_CLOUD_TEST_RUN_TOKEN…
- missing required url
- providing service name is required
- providing service version is required
- access token not configured
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/e85cbf0aa367677b.
Report an issue: GitHub.
Appendix: 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 01ffac6f24)