Skip to main content
k6 supports multiple output formats for exporting test results to different backends and file formats. You can use one or more outputs simultaneously to send metrics to various destinations.

Available Outputs

Summary Output

The default output that displays test results in the terminal at the end of the test.
k6 run script.js
See End of Test Summary for detailed information.

CSV Output

Export metrics to CSV files for analysis in spreadsheet applications.
k6 run --out csv=results.csv script.js
The CSV output (internal/output/csv/output.go:21) writes metrics with the following structure:
  • Metric name
  • Timestamp
  • Metric value
  • All tags as separate columns
CSV output supports gzip compression automatically when the filename ends with .gz:
k6 run --out csv=results.csv.gz script.js
Configuration options:
export const options = {
  ext: {
    csv: {
      fileName: 'results.csv',
      saveInterval: '5s',
      timeFormat: 'unix',
    },
  },
};

Cloud Output

Stream results to Grafana Cloud k6 for real-time analysis and collaboration.
k6 run --out cloud script.js
See Cloud Integration for details.

InfluxDB Output

Send metrics directly to InfluxDB v1 for time-series storage and visualization.
k6 run --out influxdb=http://localhost:8086/mydb script.js
The InfluxDB output (internal/output/influxdb/output.go:37) supports:
  • Configurable batch sizes
  • Concurrent writes for better performance
  • Tag-to-field conversions
  • Custom precision settings
For InfluxDB v2, use the xk6-output-influxdb extension instead.
Configuration example:
export const options = {
  ext: {
    influxdb: {
      addr: 'http://localhost:8086',
      db: 'k6',
      username: 'admin',
      password: 'admin',
      insecureSkipTLSVerify: true,
      pushInterval: '1s',
      concurrentWrites: 4,
      tagsAsFields: ['status', 'method'],
    },
  },
};

OpenTelemetry Output

Export metrics using the OpenTelemetry protocol (OTLP) for integration with observability platforms.
k6 run --out opentelemetry script.js
Supports both gRPC and HTTP transports.

Prometheus Remote Write

Send metrics to Prometheus-compatible systems using the remote write protocol.
k6 run --out prometheusrw script.js
Configuration:
export const options = {
  ext: {
    prometheusrw: {
      url: 'http://localhost:9090/api/v1/write',
      insecureSkipTLSVerify: true,
    },
  },
};

Using Multiple Outputs

You can specify multiple outputs to send results to different destinations:
k6 run --out csv=results.csv --out cloud --out influxdb=http://localhost:8086/k6 script.js
Using multiple outputs allows you to maintain local copies of results while also streaming to remote services.

Output Configuration

All outputs can be configured via:
  1. Command-line flags: --out format=config
  2. Environment variables: K6_OUT=format=config
  3. Test script options: Using the ext configuration object
  4. JSON configuration: Via the --config flag

Priority Order

Configuration sources are applied in this order (later overrides earlier):
  1. Default values
  2. JSON configuration file
  3. Script options
  4. Environment variables
  5. Command-line arguments

Output Interface

All outputs implement the Output interface (output/types.go:44) with these methods:
  • Description(): Human-readable output description
  • Start(): Initialize the output and start background processing
  • AddMetricSamples(): Receive metric samples (non-blocking)
  • Stop(): Flush remaining metrics and clean up resources
Outputs should use non-blocking AddMetricSamples() methods and buffer metrics for asynchronous flushing to avoid impacting test performance.

Output Extensions

k6 supports custom output formats through extensions. See Creating Custom Outputs for building your own output plugin. Popular community extensions:
  • xk6-output-influxdb: InfluxDB v2 support
  • xk6-output-prometheus-remote: Enhanced Prometheus integration
  • xk6-output-kafka: Stream to Apache Kafka
  • xk6-output-timescaledb: Direct TimescaleDB output

Performance Considerations

1
Buffer Metrics
2
Use SampleBuffer to collect samples before processing:
3
type Output struct {
    output.SampleBuffer
    // ...
}
4
Periodic Flushing
5
Flush metrics at regular intervals instead of per-sample:
6
pf, err := output.NewPeriodicFlusher(flushPeriod, o.flushMetrics)
7
Concurrent Writes
8
For network outputs, use concurrent connections:
9
metricPushConcurrency: 4

Build docs developers (and LLMs) love