No results for

Powered byAlgolia

Options allow you to configure how k6 will behave during test execution.

List of Options

OptionDescription
BatchMax number of simultaneous connections of a http.batch() call
Batch per hostMax number of simultaneous connections of a http.batch() call for a host
Blacklist IPsBlacklist IP ranges from being called
Block hostnamesBlock any requests to specific hostnames
Compatibility ModeSupport running scripts with different ECMAScript modes
ConfigSpecify the config file in JSON format to read the options values
Discard Response BodiesSpecify if response bodies should be discarded
DNSConfigure DNS resolution behavior
DurationA string specifying the total duration of the test run; together with the vus option, it's a shortcut for a single scenario with a constant VUs executor
Execution SegmentLimit execution to a segment of the total test
Extension OptionsAn object used to set configuration options for third-party collectors
HostsAn object with overrides to DNS resolution
HTTP DebugLog all HTTP requests and responses
Include System Env VarsPass the real system environment variables to the runtime
Insecure Skip TLS VerifyA boolean specifying whether should ignore TLS verifications for VU connections
IterationsA number specifying a fixed number of iterations to execute of the script; together with the vus option, it's a shortcut for a single scenario with a shared iterations executor
LingerA boolean specifying whether k6 should linger around after test run completion
Local IPsA list of local IPs, IP ranges, and CIDRs from which VUs will make requests
Log OutputConfiguration about where logs from k6 should be send
LogFormatSpecify the format of the log output
Max RedirectsThe maximum number of HTTP redirects that k6 will follow
Minimum Iteration DurationSpecify the minimum duration for every single execution
No Connection ReuseA boolean specifying whether k6 should disable keep-alive connections
No Cookies ResetThis disables resetting the cookie jar after each VU iteration
no summarydisables the end-of-test summary
No ThresholdsDisables threshold execution
No Usage ReportA boolean specifying whether k6 should send a usage report
No VU Connection ReuseA boolean specifying whether k6 should reuse TCP connections
PausedA boolean specifying whether the test should start in a paused state
Results OutputSpecify the results output
RPSThe maximum number of requests to make per second globally (discouraged, use arrival-rate executors instead)
ScenariosDefine advanced execution scenarios
Setup TimeoutSpecify how long the setup() function is allow to run before it's terminated
StagesA list of objects that specify the target number of VUs to ramp up or down; shortcut option for a single scenario with a ramping VUs executor
Supply Environment VariableAdd/override environment variable with VAR=value
System TagsSpecify which System Tags will be in the collected metrics
Summary ExportOutput the end-of-test summary report to a JSON file (discouraged, use handleSummary() instead)
Summary Trend StatsDefine stats for trend metrics in the end-of-test summary
Summary Time UnitTime unit to be used for all time values in the end-of-test summary
TagsSpecify tags that should be set test wide across all metrics
Teardown TimeoutSpecify how long the teardown() function is allowed to run before it's terminated
ThresholdsConfigure under what conditions a test is successful or not
ThrowA boolean specifying whether to throw errors on failed HTTP requests
TLS AuthA list of TLS client certificate configuration objects
TLS Cipher SuitesA list of cipher suites allowed to be used by in SSL/TLS interactions with a server
TLS VersionString or object representing the only SSL/TLS version allowed
User AgentA string specifying the User-Agent header when sending HTTP requests
VUsA number specifying the number of VUs to run concurrently
VUs MaxDEPRECATED

Using Options

Options can be a part of the script code so that they can be version controlled. They can also be specified with command-line flags, environment variables or via a config file. The order of precedence is as follows:

command-line flags > environment variables > exported script options > config file > defaults

Options from each level will overwrite the options from the next level, with the command-line flags having the highest precedence.

For example, you can define the duration in 4 different ways:

  • Set the duration: "10s" option in the config file
  • Set the duration: "10s" option in the script
  • Define K6_DURATION as an environment variable
  • Use the --duration 10s command-line flag: overwrites all the above.

The following JS snippet shows how to specify options in the script:

example.js
1import http from 'k6/http';
2
3export let options = {
4 hosts: { 'test.k6.io': '1.2.3.4' },
5 stages: [
6 { duration: '1m', target: 10 },
7 { duration: '1m', target: 20 },
8 { duration: '1m', target: 0 },
9 ],
10 thresholds: { http_req_duration: ['avg<100', 'p(95)<200'] },
11 noConnectionReuse: true,
12 userAgent: 'MyK6UserAgentString/1.0',
13};
14
15export default function () {
16 http.get('http://test.k6.io/');
17}

You can also set the same options through a config file:

config.json
1{
2 "hosts": {
3 "test.k6.io": "1.2.3.4"
4 },
5 "stages": [
6 {
7 "duration": "1m",
8 "target": 10
9 },
10 {
11 "duration": "1m",
12 "target": 30
13 },
14 {
15 "duration": "1m",
16 "target": 0
17 }
18 ],
19 "thresholds": {
20 "http_req_duration": ["avg<100", "p(95)<200"]
21 },
22 "noConnectionReuse": true,
23 "userAgent": "MyK6UserAgentString/1.0"
24}

Or set some of the previous options via environment variables and command-line flags:

Bash
Windows: CMD
Windows: PowerShell
$ K6_NO_CONNECTION_REUSE=true K6_USER_AGENT="MyK6UserAgentString/1.0" k6 run script.js
$ k6 run --no-connection-reuse --user-agent "MyK6UserAgentString/1.0" script.js

Below, you'll find details on all available options that can be specified within a script. It also documents the equivalent command line flag, environment variables or option when executing k6 run ... and k6 cloud ... that can be used to override options specified in the code.

Batch

The maximum number of simultaneous/parallel connections in total that an http.batch() call in a VU can make. If you have a batch() call that you've given 20 URLs to and --batch is set to 15, then the VU will make 15 requests right away in parallel and queue the rest, executing them as soon as a previous request is done and a slot opens. Available in both the k6 run and the k6 cloud commands

EnvCLICode / Config fileDefault
K6_BATCH--batchbatch20
1export let options = {
2 batch: 15,
3};

Batch per host

The maximum number of simultaneous/parallel connections for the same hostname that an http.batch() call in a VU can make. If you have a batch() call that you've given 20 URLs to the same hostname and --batch-per-host is set to 5, then the VU will make 5 requests right away in parallel and queue the rest, executing them as soon as a previous request is done and a slot opens. This will not run more request in parallel then the value of batch. Available in both the k6 run and the k6 cloud commands

EnvCLICode / Config fileDefault
K6_BATCH_PER_HOST--batch-per-hostbatchPerHost6
1export let options = {
2 batchPerHost: 5,
3};

Blacklist IPs

Blacklist IP ranges from being called. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
K6_BLACKLIST_IPS--blacklist-ipblacklistIPsnull
1export let options = {
2 blacklistIPs: ['10.0.0.0/8'],
3};

Block Hostnames

New in v0.29.0

Blocks hostnames based on a list glob match strings. The pattern matching string can have a single * at the beginning such as *.example.com that will match anything before that such as test.example.com and test.test.example.com. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
K6_BLOCK_HOSTNAMES--block-hostnamesblockHostnamesnull
1export let options = {
2 blockHostnames: ["test.k6.io" , "*.example.com"],
3};
$ k6 run --block-hostnames="test.k6.io,*.example.com" script.js

Compatibility Mode

Support running scripts with different ECMAScript compatibility modes.

Read about the different modes on the JavaScript Compatibility Mode documentation.

EnvCLICode / Config fileDefault
K6_COMPATIBILITY_MODE--compatibility-modeN/A"extended"
$ k6 run --compatibility-mode=base script.js

Config

Specify the config file in JSON format to read the options values. If the config file is not specified, k6 will look for config.json in the loadimpact/k6 directory inside the regular directory for configuration files on the operating system. Default config locations on different operating systems are:

OSDefault Config Path
Unix-based${HOME}/.config/loadimpact/k6/config.json
macOS${HOME}/Library/Application Support/loadimpact/k6/config.json
Windows%AppData%/loadimpact/k6/config.json

Available in k6 run and k6 cloud commands:

EnvCLICode / Config fileDefault
N/A--config <path>, -c <path>N/Anull

An example of a config file is available here

⚠️ Keep in mind!

When running tests in k6 Cloud and using a non-default config.json file, you will have to specify the cloud token inside your config file in order to authenticate.

Discard Response Bodies

Specify if response bodies should be discarded by changing the default value of responseType to none for all HTTP requests. Highly recommended to be set to true and then only for the requests where the response body is needed for scripting to set responseType to text or binary. Lessens the amount of memory required and the amount of GC - reducing the load on the testing machine, and probably producing more reliable test results.

EnvCLICode / Config fileDefault
K6_DISCARD_RESPONSE_BODIES--discard-response-bodiesdiscardResponseBodiesfalse
1export let options = {
2 discardResponseBodies: true,
3};

DNS

New in v0.29.0

This is a composite option that provides control of DNS resolution behavior with configuration for cache expiration (TTL), IP selection strategy and IP version preference. The TTL field in the DNS record is currently not read by k6, so the ttl option allows manual control over this behavior, albeit as a fixed value for the duration of the test run.

Note that DNS resolution is done only on new HTTP connections, and by default k6 will try to reuse connections if HTTP keep-alive is supported. To force a certain DNS behavior consider enabling the noConnectionReuse option in your tests.

EnvCLICode / Config fileDefault
K6_DNS--dnsdnsttl=5m,select=random,policy=preferIPv4

Possible ttl values are:

  • 0: no caching at all - each request will trigger a new DNS lookup.
  • inf: cache any resolved IPs for the duration of the test run.
  • any time duration like 60s, 5m30s, 10m, 2h, etc.; if no unit is specified (e.g. ttl=3000), k6 assumes milliseconds.

Possible select values are:

  • first: always pick the first resolved IP.
  • random: pick a random IP for every new connection.
  • roundRobin: iterate sequentially over the resolved IPs.

Possible policy values are:

  • preferIPv4: use IPv4 addresses if available, otherwise fall back to IPv6.
  • preferIPv6: use IPv6 addresses if available, otherwise fall back to IPv4.
  • onlyIPv4: only use IPv4 addresses, ignore any IPv6 ones.
  • onlyIPv6: only use IPv6 addresses, ignore any IPv4 ones.
  • any: no preference, use all addresses.

Here are some configuration examples:

k6 run --dns "ttl=inf,select=first,policy=any" script.js # the old k6 behavior before v0.29.0
K6_DNS="ttl=5m,select=random,policy=preferIPv4" k6 cloud script.js # new default behavior from v0.29.0
script.js
1export let options = {
2 dns: {
3 ttl: '1m',
4 select: 'roundRobin',
5 policy: 'any'
6 }
7}

Duration

A string specifying the total duration a test run should be run for. During this time each VU will execute the script in a loop. Available in k6 run and k6 cloud commands.

Together with the vus option, duration is a shortcut for a single scenario with a constant VUs executor.

EnvCLICode / Config fileDefault
K6_DURATION--duration, -ddurationnull
1export let options = {
2 vus: 100,
3 duration: '3m',
4};

Extension Options

An object used to set configuration options for third-party collectors, like plugins.

EnvCLICode / Config fileDefault
N/AN/Aextnull

This is an example of how to specify the test name (test runs/executions with the same name will be logically grouped for trending and comparison) when streaming results to k6 Cloud Performance Insights.

1export let options = {
2 ext: {
3 loadimpact: {
4 name: 'My test name',
5 },
6 },
7};

Execution Segment

New in v0.27.0

These options specify how to partition the test run and which segment to run. If defined, k6 will scale the number of VUs and iterations to be run for that segment, which is useful in distributed execution. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
N/A--execution-segmentexecutionSegment"0:1"
N/A--execution-segment-sequenceexecutionSegmentSequence"0,1"

For example, to run 25% of a test, you would specify --execution-segment '25%', which would be equivalent to --execution-segment '0:1/4', i.e. run the first 1/4 of the test. To ensure that each instance executes a specific segment, also specify the full segment sequence, e.g. --execution-segment-sequence '0,1/4,1/2,1'. This way one instance could run with --execution-segment '0:1/4', another with --execution-segment '1/4:1/2', etc. and there would be no overlap between them.

In v0.27.0 this distinction is not very important, but it will be required in future versions when support for test data partitioning is added.

Hosts

An object with overrides to DNS resolution, similar to what you can do with /etc/hosts on Linux/Unix or C:\\Windows\\System32\\drivers\\etc\\hosts on Windows. For instance, you could set up an override which routes all requests for test.k6.io to 1.2.3.4.

From v0.28.0 it is also supported to redirect only from certain ports and/or to certain ports.

⚠️ Keep in mind!

This does not modify the actual HTTP Host header, but rather where it will be routed.

EnvCLICode / Config fileDefault
N/AN/Ahostsnull
1export let options = {
2 hosts: {
3 'test.k6.io': '1.2.3.4',
4 'test.k6.io:443': '1.2.3.4:8443',
5 },
6};

With the above code any request made to test.k6.io will be redirected to 1.2.3.4 without changing it port unless it's port is 443 which will be redirected to port 8443.

HTTP Debug

Log all HTTP requests and responses. Excludes body by default, to include body use --http-debug=full. Available in k6 run and k6 cloud commands.

Read more here.

EnvCLICode / Config fileDefault
K6_HTTP_DEBUG--http-debug,
--http-debug=full
httpDebugfalse
1export let options = {
2 httpDebug: 'full',
3};

Include System Env Vars

Pass the real system environment variables to the runtime. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
N/A--include-system-env-varsN/Atrue for k6 run, but false for all other commands to prevent inadvertent sensitive data leaks.
Shell
$ k6 run --include-system-env-vars ~/script.js

Insecure Skip TLS Verify

A boolean, true or false. When this option is enabled (set to true), all of the verifications that would otherwise be done to establish trust in a server provided TLS certificate will be ignored. This only applies to connections created by VU code, such as http requests. Available in k6 run and k6 cloud commands

EnvCLICode / Config fileDefault
K6_INSECURE_SKIP_TLS_VERIFY--insecure-skip-tls-verifyinsecureSkipTLSVerifyfalse
1export let options = {
2 insecureSkipTLSVerify: true,
3};

Iterations

An integer value, specifying the total number of iterations of the default function to execute in the test run, as opposed to specifying a duration of time during which the script would run in a loop. Available both in the k6 run and k6 cloud commands.

Together with the vus option, iterations is a shortcut for a single scenario with a shared iterations executor.

By default, the maximum duration of a shared-iterations scenario is 10 minutes. You can adjust that time via the maxDuration option of the scenario, or by also specifying the duration global shortcut option.

Note that iterations aren't fairly distributed with this option, and a VU that executes faster will complete more iterations than others. Each VU will try to complete as many iterations as possible, "stealing" them from the total number of iterations for the test. So, depending on iteration times, some VUs may complete more iterations than others. If you want guarantees that every VU will complete a specific, fixed number of iterations, use the per-VU iterations executor.

EnvCLICode / Config fileDefault
K6_ITERATIONS--iterations, -iiterations1
1export let options = {
2 vus: 5,
3 iterations: 10,
4};

Or, to run 10 VUs 10 times each:

1export let options = {
2 vus: 10,
3 iterations: 100,
4};

Linger

A boolean, true or false, specifying whether the k6 process should linger around after test run completion. Available in the k6 run command.

EnvCLICode / Config fileDefault
K6_LINGER--linger, -llingerfalse
1export let options = {
2 linger: true,
3};

Local IPs

A list of IPs, IP ranges and CIDRs from which VUs will make requests. The IPs will be sequentially given out to VUs. This option doesn't change anything on the OS level so the IPs need to be already configured on the OS level in order for k6 to be able to use them. Also IPv4 CIDRs with more than 2 IPs don't include the first and last IP as they are reserved for referring to the network itself and the broadcast address respectively.

This option can be used for splitting the network traffic from k6 between multiple network cards, thus potentially increasing the available network throughput. For example, if you have 2 NICs, you can run k6 with --local-ips="<IP-from-first-NIC>,<IP-from-second-NIC>" to balance the traffic equally between them - half of the VUs will use the first IP and the other half will use the second. This can scale to any number of NICs, and you can repeat some local IPs to give them more traffic. For example, --local-ips="<IP1>,<IP2>,<IP3>,<IP3>" will split VUs between 3 different source IPs in a 25%:25%:50% ratio.

Available in the k6 run command.

EnvCLICode / Config fileDefault
K6_LOCAL_IPS--local-ipsN/AN/A
$ k6 run --local-ips=192.168.20.12-192.168.20-15,192.168.10.0/27 script.js

Log output

This option specifies where to send logs to and another configuration connected to it. Available in the k6 run command.

Possible values are:

  • none - disable
  • stdout - send to the standard output
  • stderr - send to the standard error output (this is the default)
  • loki - send logs to a loki server

The loki can additionally be configured as follows: loki=http://127.0.0.1:3100/loki/api/v1/push,label.something=else,label.foo=bar,limit=32,level=info,pushPeriod=5m32s,msgMaxSize=1231 Where all but the url in the beginning are not required. The possible keys with their meanings and default values:

keymeaningdefault value
nothingthe endpoint to which to send logshttp://127.0.0.1:3100/loki/api/v1/push
allowedLabelsif set k6 will send only the provided labels as such and all others will be appended to the message in the form key=value. The value of the option is in the form [label1,label2]N/A
label.labelNameadds an additional label with the provided key and value to each messageN/A
limitthe limit of message per pushPeriod, an additional log is send when the limit is reached, logging how many logs were dropped100
levelthe minimal level of a message so it's send to lokiall
pushPeriodat what period to send log lines1s
profilewhether to print some info about performance of the sending to lokifalse
msgMaxSizehow many symbols can there be at most in a message. Messages bigger will miss the middle of the message with an additional few characters explaining how many characters were dropped.1048576
EnvCLICode / Config fileDefault
K6_LOG_OUTPUT--log-outputN/Astderr
1$ k6 run --log-output=stdout script.js

LogFormat

A value specifying the log format. By default, k6 includes extra debug information like date and log level. The other options available are:

  • json: print all the debug information in JSON format.

  • raw: print only the log message.

EnvCLICode / Config fileDefault
K6_LOGFORMAT--logformat, -fN/A
1$ k6 run --logformat raw test.js

Max Redirects

The maximum number of HTTP redirects that k6 will follow before giving up on a request and erroring out. Available in both the k6 run and the k6 cloud commands.

EnvCLICode / Config fileDefault
K6_MAX_REDIRECTS--max-redirectsmaxRedirects10
1export let options = {
2 maxRedirects: 10,
3};

Minimum Iteration Duration

Specifies the minimum duration of every single execution (i.e. iteration) of the default function. Any iterations that are shorter than this value will cause that VU to sleep for the remainder of the time until the specified minimum duration is reached.

EnvCLICode / Config fileDefault
K6_MIN_ITERATION_DURATION--min-iteration-durationminIterationDuration0 (disabled)
1export let options = {
2 minIterationDuration: '10s',
3};

No Connection Reuse

A boolean, true or false, specifying whether k6 should disable keep-alive connections. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
K6_NO_CONNECTION_REUSE--no-connection-reusenoConnectionReusefalse
1export let options = {
2 noConnectionReuse: true,
3};

No Cookies Reset

This disables the default behavior of resetting the cookie jar after each VU iteration. If it's enabled, saved cookies will be persisted across VU iterations.

EnvCLICode / Config fileDefault
K6_NO_COOKIES_RESETN/AnoCookiesResetfalse
1export let options = {
2 noCookiesReset: true,
3};

No Summary

Disables end-of-test summary generation. Since k6 v0.30.0, that includes disabling the calling of handleSummary() and --summary-export. Available in the k6 run command.

EnvCLICode / Config fileDefault
K6_NO_SUMMARY--no-summaryN/Afalse
1$ k6 run --no-summary ~/script.js

No Thresholds

Disables threshold execution. Available in the k6 run command.

EnvCLICode / Config fileDefault
K6_NO_THRESHOLDS--no-thresholdsN/Afalse
1$ k6 run --no-thresholds ~/script.js

No Usage Report

A boolean, true or false. By default, k6 sends a usage report each time it is run, so that we can track how often people use it. If this option is set to true, no usage report will be made. To learn more, have a look at the Usage reports documentation. Available in k6 run commands.

EnvCLIConfig fileDefault
K6_NO_USAGE_REPORT--no-usage-reportnoUsageReport*false
$ k6 run --no-usage-report ~/script.js

* Note that this option is not supported in the exported script options, but can be specified in a configuration file.

No VU Connection Reuse

A boolean, true or false, specifying whether k6 should reuse TCP connections between iterations of a VU. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
K6_NO_VU_CONNECTION_REUSE--no-vu-connection-reusenoVUConnectionReusefalse
1export let options = {
2 noVUConnectionReuse: true,
3};

Paused

A boolean, true or false, specifying whether the test should start in a paused state. To resume a paused state you'd use the k6 resume command. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
K6_PAUSED--paused, -ppausedfalse
1export let options = {
2 paused: true,
3};

Results Output

Specify the results output. Please go to Results output for more information on all built-in output modules available and how to configure them. Since version 0.21, this option can be specified multiple times. Available in k6 run command.

EnvCLICode / Config fileDefault
K6_OUT--out, -oN/Anull
Shell
1$ k6 run --out influxdb=http://localhost:8086/k6 script.js

RPS

The maximum number of requests to make per second, in total across all VUs. Available in k6 run and k6 cloud commands.

⚠️ Keep in mind!

This option has some caveats and is difficult to use correctly, so its usage is somewhat discouraged. For example, in the cloud/distributed execution, this option affects every k6 instance independently, i.e. it is not sharded like VUs are. We strongly recommend the use of arrival-rate executors to simulate constant RPS instead of this option.

EnvCLICode / Config fileDefault
K6_RPS--rpsrps0 (unlimited)
1export let options = {
2 rps: 500,
3};

Considerations when running in the cloud

The option is set per load generator which means that the value you set in the options object of your test script will be multiplied by the number of load generators your test run is using. At the moment we are hosting 300 VUs per load generator instance. In practice that means that if you set the option for 100 rps, and run a test with 1000 VUs, you will spin up 4 load gen instances and effective rps limit of your test run will be 400

Scenarios

Define one or more execution patterns, with various VU and iteration scheduling settings, running different exported functions (besides default!), using different environment variables, tags, and more.

See the Scenarios article for details and more examples.

Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
N/AN/Ascenariosnull
1export let options = {
2 scenarios: {
3 my_api_scenario: {
4 // arbitrary scenario name
5 executor: 'ramping-vus',
6 startVUs: 0,
7 stages: [
8 { duration: '5s', target: 100 },
9 { duration: '5s', target: 0 },
10 ],
11 gracefulRampDown: '10s',
12 env: { MYVAR: 'example' },
13 tags: { my_tag: 'example' },
14 },
15 },
16};

Setup Timeout

Specify how long the setup() function is allow to run before it's terminated and the test fails.

EnvCLICode / Config fileDefault
K6_SETUP_TIMEOUTN/AsetupTimeout"10s"
1export let options = {
2 setupTimeout: '30s',
3};

Stages

A list of VU { target: ..., duration: ... } objects that specify the target number of VUs to ramp up or down to for a specific period. Available in k6 run and k6 cloud commands.

It is a shortcut option for a single scenario with a ramping VUs executor. If used together with the VUs option, the vus value is used as the startVUs option of the executor.

EnvCLICode / Config fileDefault
K6_STAGES--stage <duration>:<target>, -s <duration>:<target>stagesBased on vus and duration.
Code
Bash
Windows: CMD
Windows: PowerShell
// The following config would have k6 ramping up from 1 to 10 VUs for 3 minutes,
// then staying flat at 10 VUs for 5 minutes, then ramping up from 10 to 35 VUs
// over the next 10 minutes before finally ramping down to 0 VUs for another
// 3 minutes.
export let options = {
stages: [
{ duration: '3m', target: 10 },
{ duration: '5m', target: 10 },
{ duration: '10m', target: 35 },
{ duration: '3m', target: 0 },
],
};

Summary export

New in v0.26.0

Save the end-of-test summary report to a JSON file that includes data for all test metrics, checks and thresholds. This is useful to get the aggregated test results in a machine-readable format, for integration with dashboards, external alerts, CI pipelines, etc.

Starting with k6 v0.30.0, while this feature is not deprecated yet, its usage is discouraged, see the explanation why here. For a better and more flexible JSON export, as well as export of the summary data to different formats (e.g. JUnit/XUnit/etc. XML, HTML, .txt) and complete summary customization, see the new handleSummary() callback.

Available in the k6 run command.

EnvCLICode / Config fileDefault
K6_SUMMARY_EXPORT--summary-export <filename>N/Anull
Bash
Windows: CMD
Windows: PowerShell
$ k6 run --summary-export export.json script.js
# or...
$ K6_SUMMARY_EXPORT="export.json" k6 run script.js

See an example file on the Results Output page.

Supply environment variables

Add/override an environment variable with VAR=valuein a k6 script. Available in k6 run and k6 cloud commands.

To make the system environment variables available in the k6 script via __ENV, use the --include-system-env-vars option.

Note: This can not be used to configure k6 with environment variables as listed on this page. In other words -e K6_ITERATIONS=120 will not configure the script iterations, it will just provide __ENV.K6_ITERATIONS to the script, unlike K6_ITERATIONS=120 k6 run script.js.

EnvCLICode / Config fileDefault
N/A--env, -eN/Anull
Shell
1$ k6 run -e FOO=bar ~/script.js

System Tags

Specify which System Tags will be in the collected metrics. Some collectors like the cloud one may require that certain system tags be used. You can specify the tags as an array from the JS scripts or as a comma-separated list via the CLI. Available in k6 run and k6 cloud commands

EnvCLICode / Config fileDefault
K6_SYSTEM_TAGS--system-tagssystemTagsproto,subproto,status,method,url,name,group, check,error,tls_version,scenario,service,rpc_type,expected_response
1export let options = {
2 systemTags: ['status', 'method', 'url'],
3};

Summary Time Unit

Define which time unit will be used for all time values in the end-of-test summary. Possible values are s (seconds), ms (milliseconds) and us (microseconds). If no value is specified, k6 will use mixed time units, choosing the most appropriate unit for each value.

EnvCLICode / Config fileDefault
K6_SUMMARY_TIME_UNIT--summary-time-unitsummaryTimeUnitnull
1export let options = {
2 summaryTimeUnit: 'ms',
3};

Summary Trend Stats

Define which stats for Trend metrics (e.g. response times, group/iteration durations, etc.) will be shown in the end-of-test summary. Possible values include avg (average), med (median), min, max, count (since k6 v0.26.0), as well as arbitrary percentile values (e.g. p(95), p(99), p(99.99), etc.).

For further summary customization and exporting the summary in various formats (e.g. JSON, JUnit/XUnit/etc. XML, HTML, .txt, etc.), see the new handleSummary() callback introduced in k6 v0.30.0.

EnvCLICode / Config fileDefault
K6_SUMMARY_TREND_STATS--summary-trend-statssummaryTrendStatsavg,min,med,max,p(90),p(95)
1export let options = {
2 summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.99)', 'count'],
3};
Shell
1$ k6 run --summary-trend-stats="avg,min,med,max,p(90),p(99.9),p(99.99),count" ./script.js

Tags

Specify tags that should be set test wide across all metrics. If a tag with the same name has been specified on a request, check or custom metrics it will have precedence over a test wide tag. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
N/A--tag NAME=VALUEtagsnull
1export let options = {
2 tags: {
3 name: 'value',
4 },
5};

Teardown Timeout

Specify how long the teardown() function is allowed to run before it's terminated and the test fails.

EnvCLICode / Config fileDefault
K6_TEARDOWN_TIMEOUTN/AteardownTimeout"10s"
1export let options = {
2 teardownTimeout: '30s',
3};

Thresholds

A collection of threshold specifications to configure under what condition(s) a test is considered successful or not, when it has passed or failed, based on metric data. To learn more, have a look at the Thresholds documentation. Available in k6 run commands.

EnvCLICode / Config fileDefault
N/AN/Athresholdsnull
1export let options = {
2 thresholds: {
3 http_req_duration: ['avg<100', 'p(95)<200'],
4 'http_req_connecting{cdnAsset:true}': ['p(95)<100'],
5 },
6};

Throw

A boolean, true or false, specifying whether to throw errors on failed HTTP requests or not. Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
K6_THROW--throw, -wthrowfalse
1export let options = {
2 throw: true,
3};

TLS Auth

A list of TLS client certificate configuration objects. Each object needs to specify for which host(s)/domain(s) the given client certificate is valid for.

EnvCLICode / Config fileDefault
N/AN/AtlsAuthnull
1export let options = {
2 tlsAuth: [
3 {
4 domains: ['example.com'],
5 cert: open('mycert.pem'),
6 key: open('mycert-key.pem'),
7 },
8 ],
9};

TLS Cipher Suites

A list of cipher suites allowed to be used by in SSL/TLS interactions with a server. For a full listing of available ciphers go here.

⚠️ Keep in mind!

Due to limitations in the underlying go implementation changing of the ciphers for TLS 1.3 is not supported and will do nothing.

EnvCLICode / Config fileDefault
N/AN/AtlsCipherSuitesnull (Allow all suites)
1export let options = {
2 tlsCipherSuites: [
3 'TLS_RSA_WITH_RC4_128_SHA',
4 'TLS_RSA_WITH_AES_128_GCM_SHA256',
5 ],
6};

TLS Version

Either a string representing the only SSL/TLS version allowed to be used in interactions with a server, or an object specifying the "min" and "max" versions allowed to be used.

EnvCLICode / Config fileDefault
N/AN/AtlsVersionnull (Allow all versions)
1export let options = {
2 tlsVersion: 'tls1.2',
3};
4
5// or...
6
7export let options = {
8 tlsVersion: {
9 min: 'ssl3.0',
10 max: 'tls1.2',
11 },
12};

User Agent

A string specifying the user-agent string to use in User-Agent headers when sending HTTP requests. Setting it to an empty string will not send a User-Agent header since v0.29.0. Available in k6 run and k6 cloud commands

EnvCLICode / Config fileDefault
K6_USER_AGENT--user-agentuserAgentk6/0.27.0 (https://k6.io/) (depending on the version you're using)`
1export let options = {
2 userAgent: 'MyK6UserAgentString/1.0',
3};

VUs

An integer value specifying the number of VUs to run concurrently, used together with the iterations or duration options. If you'd like more control look at the stages option or scenarios.

Available in k6 run and k6 cloud commands.

EnvCLICode / Config fileDefault
K6_VUS--vus, -uvus1
1export let options = {
2 vus: 10,
3 duration: '1h',
4};

VUs Max

⚠️ Keep in mind!

This option was deprecated in k6 version 0.27.0. See scenarios and the externally controlled executor instead.

EnvCLICode / Config fileDefault
K6_VUS_MAX--max, -mvusMax0 (unlimited)