k6 --out: Stream Results to a Backend
k6 run --out <type> streams each metric sample to an external destination so you can dashboard load-test trends instead of reading terminal summaries.
The end-of-run summary is fine for a quick check, but for trends you want the time series. --out ships samples to files or backends during the run.
What it does
k6 run --out <type>=<args> sends every metric sample to the named output. Built-ins include json and csv files, InfluxDB, and Prometheus remote write (experimental-prometheus-rw). You can pass --out more than once to fan out.
Common usage
k6 run --out json=results.json script.js
k6 run --out csv=metrics.csv script.js
# push to Prometheus via remote write
K6_PROMETHEUS_RW_SERVER_URL=http://prom:9090/api/v1/write \
k6 run --out experimental-prometheus-rw script.js
# legacy InfluxDB
k6 run --out influxdb=http://influx:8086/k6 script.jsOptions
| Output | What it does |
|---|---|
| json=<file> | Write newline-delimited JSON samples |
| csv=<file> | Write CSV samples |
| experimental-prometheus-rw | Prometheus remote write (env-configured) |
| influxdb=<url> | Stream to InfluxDB |
| K6_PROMETHEUS_RW_SERVER_URL | Remote-write endpoint for the Prometheus output |
| --out a --out b | Multiple outputs at once |
In CI
Write --out json=results.json and upload it as a build artifact so a run is reproducible after the fact. For a shared dashboard, push to Prometheus remote write or InfluxDB with the endpoint and credentials supplied via env vars from CI secrets.
Common errors in CI
"invalid output type 'prometheus'" means you named the output wrong; the type is experimental-prometheus-rw. "level=error msg=\"... no such host\"" or a connection refused means the backend URL is unreachable from the runner. The Prometheus output silently sends nothing if K6_PROMETHEUS_RW_SERVER_URL is unset.