Skip to main content

Real-Time Result Streaming

Besides the end-of-test summary, k6 can stream metrics as granular data points in real time. This enables live monitoring, long-term storage, and integration with external observability platforms.

Overview

Real-time streaming allows you to:
  • Monitor test progress as it runs
  • Store metrics for historical analysis
  • Integrate with existing monitoring systems
  • Build custom dashboards and alerts
  • Process metrics with your own tools
You can stream metrics to either files or external services using the --out flag.

Output to Files

k6 supports streaming metrics to local files in two formats:

CSV

Simple, human-readable format

JSON

Structured format with full metadata

CSV Output

CSV output provides a simple, tabular format with one metric value per line:
You can also compress the output automatically:
CSV Format:
CSV Configuration: Monitor in real time:

JSON Output

JSON output provides structured data with complete metric metadata:
Or compressed:
JSON Format: Each line contains either a metric definition or a data point:
Process with jq:
For the aggregated end-of-test summary as JSON, use the handleSummary() function instead of --out json.

Output to Services

k6 can stream metrics to various external services and databases:
Stream directly to Grafana Cloud k6 for managed storage and visualization:
Requires a Grafana Cloud k6 account.

InfluxDB Example

Here’s a complete workflow for streaming to InfluxDB v2:
1

Install xk6

2

Build k6 with extension

3

Run test

4

Visualize in Grafana

Connect Grafana to your InfluxDB instance and use pre-built dashboards or create custom ones.
InfluxDB v2 Configuration Options:

Multiple Outputs

You can stream to multiple destinations simultaneously:
This is useful for:
  • Archiving raw data while monitoring in real time
  • Sending to multiple monitoring systems
  • Creating backups of test results

Docker Example

Stream results when running k6 in Docker:
Ensure the Docker user has write permissions to the output directory.

Performance Considerations

Streaming real-time metrics can impact test performance, especially at high load. Consider:
  • Increasing saveInterval or pushInterval for high-throughput tests
  • Using efficient backends (InfluxDB, Prometheus) instead of JSON files
  • Running k6 and the monitoring backend on separate machines
  • Monitoring the resource usage of both k6 and the output backend

Building Custom Output Extensions

You can create your own output format using xk6:
For details, see the output extension documentation.

Next Steps

Grafana Dashboards

Visualize real-time metrics with Grafana

Web Dashboard

Use the built-in web dashboard for live monitoring

Metrics Reference

Learn about all available k6 metrics

Output Extensions

Build custom output formats