<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Get started on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/get-started/</link><description>Recent content in Get started on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/get-started/index.xml" rel="self" type="application/rss+xml"/><item><title>Write your first test</title><link>https://grafana.com/docs/k6/v2.3.x/get-started/write-your-first-test/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/get-started/write-your-first-test/</guid><content><![CDATA[&lt;h1 id=&#34;write-your-first-test&#34;&gt;Write your first test&lt;/h1&gt;
&lt;p&gt;k6 is a reliability testing tool. It helps developers simulate realistic user behavior and test how their systems behave as a result. Writing tests in k6 allows you to identify potential issues, such as slow response times or system failures, before they occur in production.&lt;/p&gt;
&lt;p&gt;The goal of your test can vary. You might want to check performance, reliability, or scalability. Depending on your goal, your script may need different configurations, such as simulating many users, or running tests for a long time.&lt;/p&gt;
&lt;p&gt;k6 tests are written using the JavaScript or TypeScript programming language, making it accessible to developers, and easy to integrate in existing codebases and projects. By writing k6 test scripts, you control what the k6 does, the action it performs, and how it behaves.&lt;/p&gt;
&lt;p&gt;Follow along and learn how to write your first test script, and start testing the reliability of your application.&lt;/p&gt;




&lt;div class=&#34;d-sm-flex flex-direction-row-reverse bg-gray-1 br-12 p-2 my-1&#34;&gt;
  &lt;img class=&#34;maxw-240 w-100p mb-1 lazyload&#34; data-src=&#34;/media/docs/learning-journey/map.svg&#34; width=&#34;237&#34; height=&#34;154&#34; alt=&#34;Grafana Learning Journeys&#34;&gt;
  &lt;div&gt;
    &lt;div class=&#34;h4 pt-0 pb-half fw-500&#34;&gt;Start your learning experience with Grafana Learning Paths&lt;/div&gt;
    &lt;p class=&#34;pr-1 pb-half&#34;&gt;Grafana Learning Paths provide a clear, structured path that leads you from beginner concepts to advanced use cases. Learn about this Grafana feature on &lt;a href=&#34;/docs/learning-paths/run-first-k6-test/&#34;&gt;Run your first k6 performance test&lt;/a&gt;.&lt;/p&gt;
    &lt;div class=&#34;mx-auto&#34;&gt;
      &lt;a class=&#34;btn btn--primary btn--large arrow fw-600 br-8 w-175&#34; href=&#34;https://grafana.com/docs/learning-paths/run-first-k6-test/&#34;&gt;Start learning&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&#34;before-you-start&#34;&gt;Before you start&lt;/h2&gt;
&lt;p&gt;To write k6 scripts, you&amp;rsquo;ll need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A basic knowledge of JavaScript or TypeScript.
&lt;ul&gt;
&lt;li&gt;If you&amp;rsquo;re unfamiliar with these languages, check out 
    &lt;a href=&#34;/docs/k6/v2.3.x/k6-studio/&#34;&gt;k6 Studio&lt;/a&gt;, which helps users generate tests without writing code. Alternatively, explore our 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-authoring/&#34;&gt;test authoring methods&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/set-up/&#34;&gt;Install k6&lt;/a&gt; in your machine.&lt;/li&gt;
&lt;li&gt;A code editor to write your scripts, such as &lt;a href=&#34;https://code.visualstudio.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Visual Studio Code&lt;/a&gt; or &lt;a href=&#34;https://www.jetbrains.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JetBrains editors&lt;/a&gt;.
&lt;ul&gt;
&lt;li&gt;Refer to 
    &lt;a href=&#34;/docs/k6/v2.3.x/set-up/configure-your-code-editor/&#34;&gt;Configure your code editor&lt;/a&gt; to learn how to enable auto-completion and other features.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;basic-structure-of-a-k6-test&#34;&gt;Basic structure of a k6 test&lt;/h2&gt;
&lt;p&gt;For k6 to be able to interpret and execute your test, every k6 script follows a common structure, revolving around a few core components:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Default function&lt;/strong&gt;: This is where the test logic resides. It defines what your test will do and how it will behave during execution. It should be exported as the default function in your script.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Imports&lt;/strong&gt;: You can import additional 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/&#34;&gt;k6 modules&lt;/a&gt; or 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/jslib/&#34;&gt;JavaScript libraries (jslibs)&lt;/a&gt; to extend your script’s functionality, such as making HTTP requests or simulating browser interactions. Note that k6 is not built upon Node.js, and instead uses its own JavaScript runtime. Compatibility with some npm modules may vary.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Options (optional)&lt;/strong&gt;: Enable you to configure the execution of the test, such as defining the number of virtual users, the test duration, or setting performance thresholds. Refer to 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/k6-options/&#34;&gt;Options&lt;/a&gt; for more details.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lifecycle operations (optional)&lt;/strong&gt;: Because your test might need to run code before and/or after the execution of the test logic, such as parsing data from a file, or download an object from Amazon S3, 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;lifecycle operations&lt;/a&gt; allow you to write code, either as predefined functions or within specific code scopes, that will be executed at different stages of the test execution.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;writing-your-first-test-script&#34;&gt;Writing your first test script&lt;/h3&gt;
&lt;p&gt;Let’s walk through creating a simple test which performs 10 &lt;code&gt;GET&lt;/code&gt; HTTP requests to a URL and waits for 1 second between requests. This script will help you understand the basic structure of a k6 test script.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a test file&lt;/strong&gt;: A test file can be named anything you like, and live wherever you see fit in your project, but it should have a &lt;code&gt;.js&lt;/code&gt; or &lt;code&gt;.ts&lt;/code&gt; extension. In this example, create a JavaScript file named &lt;code&gt;my-first-test.js&lt;/code&gt;. Open your terminal and run the following command:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;touch my-first-test.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Import k6 modules&lt;/strong&gt;: As the end goal here is to perform HTTP requests, import the k6 &lt;code&gt;http&lt;/code&gt; module at the top of the file. To help simulate a real-world scenario, import the &lt;code&gt;sleep&lt;/code&gt; function from the &lt;code&gt;k6&lt;/code&gt; module as well.&lt;/p&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;// Import the http module to make HTTP requests. From this point, you can use `http` methods to make HTTP requests.
import http from &amp;#39;k6/http&amp;#39;;

// Import the sleep function to introduce delays. From this point, you can use the `sleep` function to introduce delays in your test script.
import { sleep } from &amp;#39;k6&amp;#39;;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Define options&lt;/strong&gt;: To perform 10 HTTP requests, define an options block to configure the test execution. In this case, set the number of iterations to 10 to instruct k6 to execute the default function 10 times. Right beneath the imports, add the following code:&lt;/p&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { sleep } from &amp;#39;k6&amp;#39;;

export const options = {
  // Define the number of iterations for the test
  iterations: 10,
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Define a default function&lt;/strong&gt;: The default exported function is the entry point for the test script. It will be executed repeatedly the number of times you define with the &lt;code&gt;iterations&lt;/code&gt; option. In this function, make a &lt;code&gt;GET&lt;/code&gt; request to a URL and introduce a 1-second delay between requests. Add the following code to your script:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { sleep } from &amp;#39;k6&amp;#39;;

export const options = {
  iterations: 10,
};

// The default exported function is gonna be picked up by k6 as the entry point for the test script. It will be executed repeatedly in &amp;#34;iterations&amp;#34; for the whole duration of the test.
export default function () {
  // Make a GET request to the target URL
  http.get(&amp;#39;https://quickpizza.grafana.com&amp;#39;);

  // Sleep for 1 second to simulate real-world usage
  sleep(1);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;extending-your-script&#34;&gt;Extending your script&lt;/h3&gt;
&lt;p&gt;After you&amp;rsquo;re comfortable with this basic script, you can extend its functionality in many ways. Here are a few ideas to get you started:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Multiple requests&lt;/strong&gt;: You can add more &lt;code&gt;http.get()&lt;/code&gt; or &lt;code&gt;http.post()&lt;/code&gt; requests to simulate complex user flows.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Using TypeScript&lt;/strong&gt;: If you prefer TypeScript, k6 also supports it. You can learn more in our 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/javascript-typescript-compatibility-mode/#typescript-support&#34;&gt;TypeScript guide&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Thresholds, checks, and metrics&lt;/strong&gt;: You can add conditions to monitor performance. For example, you can set thresholds to ensure the response time doesn’t exceed a certain limit. Refer to 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/thresholds/&#34;&gt;Thresholds&lt;/a&gt; and 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/checks/&#34;&gt;Checks&lt;/a&gt; for more details.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Browser tests&lt;/strong&gt;: Use the browser module to simulate user interactions like clicking buttons or filling out forms. This is useful for testing web applications. Refer to 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6-browser/&#34;&gt;Using k6 browser&lt;/a&gt; for more details.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can also use the &lt;code&gt;k6 new&lt;/code&gt; command to speed up the process of putting together a k6 test script when you&amp;rsquo;re testing a new service or application. Try it out!&lt;/p&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Now that you’ve written your first k6 test script, it’s time to run it. Refer to 
    &lt;a href=&#34;/docs/k6/v2.3.x/get-started/running-k6/&#34;&gt;Running k6&lt;/a&gt; to learn how to execute your script and analyze the results.&lt;/p&gt;
]]></content><description>&lt;h1 id="write-your-first-test">Write your first test&lt;/h1>
&lt;p>k6 is a reliability testing tool. It helps developers simulate realistic user behavior and test how their systems behave as a result. Writing tests in k6 allows you to identify potential issues, such as slow response times or system failures, before they occur in production.&lt;/p></description></item><item><title>Running k6</title><link>https://grafana.com/docs/k6/v2.3.x/get-started/running-k6/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/get-started/running-k6/</guid><content><![CDATA[&lt;h1 id=&#34;running-k6&#34;&gt;Running k6&lt;/h1&gt;
&lt;p&gt;Follow along to learn how to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Run a test.&lt;/li&gt;
&lt;li&gt;Add virtual users.&lt;/li&gt;
&lt;li&gt;Increase the test duration.&lt;/li&gt;
&lt;li&gt;Ramp the number of requests up and down as the test runs.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With these example snippets, you&amp;rsquo;ll run the test with your machine&amp;rsquo;s resources.
But, if you have a k6 Cloud account, you can also use the &lt;code&gt;k6 cloud run&lt;/code&gt; command to outsource the test to k6 servers.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/set-up/install-k6/&#34;&gt;Install k6&lt;/a&gt; on your machine.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;run-local-tests&#34;&gt;Run local tests&lt;/h2&gt;
&lt;p&gt;To run a simple local script:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create and initialize a new script by running the following command:&lt;/p&gt;



  

  

  






  

  

  



  &lt;div class=&#34;code&#34; x-data=&#34;app_code([&amp;#34;linux&amp;#34;,&amp;#34;docker&amp;#34;,&amp;#34;windows&amp;#34;], false)&#34; x-init=&#34;init()&#34; data-codetoggle=&#34;true&#34;&gt;
    &lt;div class=&#34;toggle-toolbar &#34;&gt;
      &lt;div&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;linux&#39; }&#34; @click=&#34;$store.code.language = &#39;linux&#39;&#34;&gt;
              &lt;span&gt;linux&lt;/span&gt;
            &lt;/button&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;docker&#39; }&#34; @click=&#34;$store.code.language = &#39;docker&#39;&#34;&gt;
              &lt;span&gt;docker&lt;/span&gt;
            &lt;/button&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;windows&#39; }&#34; @click=&#34;$store.code.language = &#39;windows&#39;&#34;&gt;
              &lt;span&gt;windows&lt;/span&gt;
            &lt;/button&gt;&lt;/div&gt;
      &lt;div class=&#34;d-flex&#34;&gt;&lt;span class=&#34;code-clipboard&#34; x-ref=&#34;tooltip&#34;&gt;
          &lt;button @click=&#34;copy()&#34;&gt;
            &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
            &lt;span&gt;Copy&lt;/span&gt;
          &lt;/button&gt;
        &lt;/span&gt;
      &lt;/div&gt;
      &lt;div class=&#34;toggle-toolbar__border&#34;&gt;&lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&#34;code-rendered&#34; &gt;
      
&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;linux&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-linux&#34;&gt;k6 new&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;docker&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-docker&#34;&gt;docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;windows&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-windows&#34;&gt;docker run --rm -i -v ${PWD}:/app -w /app grafana/k6 new&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

    &lt;/div&gt;
  &lt;/div&gt;


&lt;p&gt;This command creates a new script file named &lt;code&gt;script.js&lt;/code&gt; in the current directory.
You can also specify a different file name as an argument to the &lt;code&gt;k6 new&lt;/code&gt; command, for example &lt;code&gt;k6 new my-test.js&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run k6 with the following command:&lt;/p&gt;



  

  

  






  

  

  



  &lt;div class=&#34;code&#34; x-data=&#34;app_code([&amp;#34;linux&amp;#34;,&amp;#34;docker&amp;#34;,&amp;#34;windows&amp;#34;], false)&#34; x-init=&#34;init()&#34; data-codetoggle=&#34;true&#34;&gt;
    &lt;div class=&#34;toggle-toolbar &#34;&gt;
      &lt;div&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;linux&#39; }&#34; @click=&#34;$store.code.language = &#39;linux&#39;&#34;&gt;
              &lt;span&gt;linux&lt;/span&gt;
            &lt;/button&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;docker&#39; }&#34; @click=&#34;$store.code.language = &#39;docker&#39;&#34;&gt;
              &lt;span&gt;docker&lt;/span&gt;
            &lt;/button&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;windows&#39; }&#34; @click=&#34;$store.code.language = &#39;windows&#39;&#34;&gt;
              &lt;span&gt;windows&lt;/span&gt;
            &lt;/button&gt;&lt;/div&gt;
      &lt;div class=&#34;d-flex&#34;&gt;&lt;span class=&#34;code-clipboard&#34; x-ref=&#34;tooltip&#34;&gt;
          &lt;button @click=&#34;copy()&#34;&gt;
            &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
            &lt;span&gt;Copy&lt;/span&gt;
          &lt;/button&gt;
        &lt;/span&gt;
      &lt;/div&gt;
      &lt;div class=&#34;toggle-toolbar__border&#34;&gt;&lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&#34;code-rendered&#34; &gt;
      
&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;linux&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-linux&#34;&gt;k6 run script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;docker&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-docker&#34;&gt;# When using the `k6` docker image, you can&amp;#39;t just give the script name since
# the script file will not be available to the container as it runs. Instead
# you must tell k6 to read `stdin` by passing the file name as `-`. Then you
# pipe the actual file into the container with `&amp;lt;` or equivalent. This will
# cause the file to be redirected into the container and be read by k6.

docker run --rm -i grafana/k6 run - &amp;lt;script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;windows&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-windows&#34;&gt;cat script.js | docker run --rm -i grafana/k6 run -&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

    &lt;/div&gt;
  &lt;/div&gt;


&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;add-vus&#34;&gt;Add VUs&lt;/h2&gt;
&lt;p&gt;Now run a load test with more than one virtual user and a longer duration:&lt;/p&gt;



  

  

  






  

  

  



  &lt;div class=&#34;code&#34; x-data=&#34;app_code([&amp;#34;linux&amp;#34;,&amp;#34;docker&amp;#34;,&amp;#34;windows&amp;#34;], false)&#34; x-init=&#34;init()&#34; data-codetoggle=&#34;true&#34;&gt;
    &lt;div class=&#34;toggle-toolbar &#34;&gt;
      &lt;div&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;linux&#39; }&#34; @click=&#34;$store.code.language = &#39;linux&#39;&#34;&gt;
              &lt;span&gt;linux&lt;/span&gt;
            &lt;/button&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;docker&#39; }&#34; @click=&#34;$store.code.language = &#39;docker&#39;&#34;&gt;
              &lt;span&gt;docker&lt;/span&gt;
            &lt;/button&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;windows&#39; }&#34; @click=&#34;$store.code.language = &#39;windows&#39;&#34;&gt;
              &lt;span&gt;windows&lt;/span&gt;
            &lt;/button&gt;&lt;/div&gt;
      &lt;div class=&#34;d-flex&#34;&gt;&lt;span class=&#34;code-clipboard&#34; x-ref=&#34;tooltip&#34;&gt;
          &lt;button @click=&#34;copy()&#34;&gt;
            &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
            &lt;span&gt;Copy&lt;/span&gt;
          &lt;/button&gt;
        &lt;/span&gt;
      &lt;/div&gt;
      &lt;div class=&#34;toggle-toolbar__border&#34;&gt;&lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&#34;code-rendered&#34; &gt;
      
&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;linux&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-linux&#34;&gt;k6 run --vus 10 --duration 30s script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;docker&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-docker&#34;&gt;docker run --rm -i grafana/k6 run --vus 10 --duration 30s - &amp;lt;script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;windows&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-windows&#34;&gt;cat script.js | docker run --rm -i grafana/k6 run --vus 10 --duration 30s -&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

    &lt;/div&gt;
  &lt;/div&gt;


&lt;p&gt;&lt;em&gt;Running a 30-second, 10-VU load test&lt;/em&gt;&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;k6 runs multiple iterations in parallel with &lt;em&gt;virtual users&lt;/em&gt; (VUs).
In general terms, more virtual users means more simulated traffic.&lt;/p&gt;
&lt;p&gt;VUs are essentially parallel &lt;code&gt;while(true)&lt;/code&gt; loops.
Scripts are written in JavaScript, as ES6 modules,
so you can break larger tests into smaller pieces or make reusable pieces as you like.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;the-init-context-and-the-default-function&#34;&gt;The init context and the default function&lt;/h3&gt;
&lt;p&gt;For a test to run, you need to have &lt;em&gt;init code&lt;/em&gt;, which prepares the test, and &lt;em&gt;VU code,&lt;/em&gt; which makes requests.&lt;/p&gt;
&lt;p&gt;Code in the init context defines functions and configures the test options (like &lt;code&gt;duration&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Every test also has a &lt;code&gt;default&lt;/code&gt; function,
which defines the VU logic.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;// init

export default function () {
  // vu code: do things here...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Init code runs first and is called only once per VU.
The &lt;code&gt;default&lt;/code&gt; code runs as many times or as long as is configured in the test options.&lt;/p&gt;
&lt;p&gt;To learn more about how k6 executes, read about the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;Test lifecycle&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;set-options&#34;&gt;Set options&lt;/h2&gt;
&lt;p&gt;Instead of typing &lt;code&gt;--vus 10&lt;/code&gt; and &lt;code&gt;--duration 30s&lt;/code&gt; each time you run the script,
you can set the options in your JavaScript file:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { sleep } from &amp;#39;k6&amp;#39;;
export const options = {
  vus: 10,
  duration: &amp;#39;30s&amp;#39;,
};
export default function () {
  http.get(&amp;#39;http://test.k6.io&amp;#39;);
  sleep(1);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you run the script without flags, k6 uses the options defined in the script:&lt;/p&gt;



  

  

  






  

  

  



  &lt;div class=&#34;code&#34; x-data=&#34;app_code([&amp;#34;linux&amp;#34;,&amp;#34;docker&amp;#34;,&amp;#34;windows&amp;#34;], false)&#34; x-init=&#34;init()&#34; data-codetoggle=&#34;true&#34;&gt;
    &lt;div class=&#34;toggle-toolbar &#34;&gt;
      &lt;div&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;linux&#39; }&#34; @click=&#34;$store.code.language = &#39;linux&#39;&#34;&gt;
              &lt;span&gt;linux&lt;/span&gt;
            &lt;/button&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;docker&#39; }&#34; @click=&#34;$store.code.language = &#39;docker&#39;&#34;&gt;
              &lt;span&gt;docker&lt;/span&gt;
            &lt;/button&gt;&lt;button class=&#34;toggle-toolbar__item&#34; :class=&#34;{ &#39;toggle-toolbar__item-active&#39;: active === &#39;windows&#39; }&#34; @click=&#34;$store.code.language = &#39;windows&#39;&#34;&gt;
              &lt;span&gt;windows&lt;/span&gt;
            &lt;/button&gt;&lt;/div&gt;
      &lt;div class=&#34;d-flex&#34;&gt;&lt;span class=&#34;code-clipboard&#34; x-ref=&#34;tooltip&#34;&gt;
          &lt;button @click=&#34;copy()&#34;&gt;
            &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
            &lt;span&gt;Copy&lt;/span&gt;
          &lt;/button&gt;
        &lt;/span&gt;
      &lt;/div&gt;
      &lt;div class=&#34;toggle-toolbar__border&#34;&gt;&lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class=&#34;code-rendered&#34; &gt;
      
&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;linux&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-linux&#34;&gt;k6 run script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;docker&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-docker&#34;&gt;docker run --rm -i grafana/k6 run - &amp;lt;script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;windows&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-windows&#34;&gt;cat script.js | docker run --rm -i grafana/k6 run -&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

    &lt;/div&gt;
  &lt;/div&gt;


&lt;h2 id=&#34;ramp-vus-up-and-down-in-stages&#34;&gt;Ramp VUs up and down in stages&lt;/h2&gt;
&lt;p&gt;You can ramp the number of VUs up and down during the test.
To configure ramping, use the &lt;code&gt;options.stages&lt;/code&gt; property.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { check, sleep } from &amp;#39;k6&amp;#39;;

export const options = {
  stages: [
    { duration: &amp;#39;30s&amp;#39;, target: 20 },
    { duration: &amp;#39;1m30s&amp;#39;, target: 10 },
    { duration: &amp;#39;20s&amp;#39;, target: 0 },
  ],
};

export default function () {
  const res = http.get(&amp;#39;https://quickpizza.grafana.com/&amp;#39;);
  check(res, { &amp;#39;status was 200&amp;#39;: (r) =&amp;gt; r.status == 200 });
  sleep(1);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For more granular ramp configuration, you can use 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/scenarios/&#34;&gt;scenarios&lt;/a&gt; and the &lt;code&gt;ramping-vus&lt;/code&gt; executor.&lt;/p&gt;
&lt;h2 id=&#34;execution-modes&#34;&gt;Execution modes&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Portability is a major design goal of k6.&lt;/p&gt;
&lt;p&gt;You can run the same test in different modes with minimal changes.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;k6 supports three execution modes to run a k6 test: local, distributed, and cloud.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Local&lt;/strong&gt;: the test execution happens entirely on a single machine, container, or CI server.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 run script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Distributed&lt;/strong&gt;: the test execution is 
    &lt;a href=&#34;/docs/k6/v2.3.x/set-up/set-up-distributed-k6/&#34;&gt;distributed across a Kubernetes cluster&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Save the following YAML as &lt;code&gt;k6-testrun-resource.yaml&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;---
apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
  name: k6-sample
spec:
  parallelism: 4
  script:
    configMap:
      name: &amp;#39;k6-test&amp;#39;
      file: &amp;#39;script.js&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Apply the resource with the following command:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;kubectl apply -f /path/to/k6-testrun-resource.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cloud&lt;/strong&gt;: the test runs on &lt;a href=&#34;/docs/grafana-cloud/testing/k6/get-started/run-cloud-tests-from-the-cli/&#34;&gt;Grafana Cloud k6&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 cloud run script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Additionally, cloud-based solutions can run cloud tests on your &lt;a href=&#34;/docs/grafana-cloud/testing/k6/author-run/private-load-zone-v2/&#34;&gt;own cloud infrastructure&lt;/a&gt;, and accept the test results from a 
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/cloud/&#34;&gt;local&lt;/a&gt; or &lt;a href=&#34;https://github.com/grafana/k6-operator#k6-cloud-output&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;distributed test&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="running-k6">Running k6&lt;/h1>
&lt;p>Follow along to learn how to:&lt;/p>
&lt;ol>
&lt;li>Run a test.&lt;/li>
&lt;li>Add virtual users.&lt;/li>
&lt;li>Increase the test duration.&lt;/li>
&lt;li>Ramp the number of requests up and down as the test runs.&lt;/li>
&lt;/ol>
&lt;p>With these example snippets, you&amp;rsquo;ll run the test with your machine&amp;rsquo;s resources.
But, if you have a k6 Cloud account, you can also use the &lt;code>k6 cloud run&lt;/code> command to outsource the test to k6 servers.&lt;/p></description></item><item><title>Results output</title><link>https://grafana.com/docs/k6/v2.3.x/get-started/results-output/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/get-started/results-output/</guid><content><![CDATA[&lt;h1 id=&#34;results-output&#34;&gt;Results output&lt;/h1&gt;
&lt;p&gt;As k6 generates load for your test, it also makes &lt;em&gt;metrics&lt;/em&gt; that measure the performance of the system.
Broadly, you can analyze metrics in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;As summary statistics, in an &lt;em&gt;end-of-test&lt;/em&gt; summary report.&lt;/li&gt;
&lt;li&gt;In granular detail, with measurements for every data point across test (and timestamps)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can customize almost every aspect of result output:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create custom metrics&lt;/li&gt;
&lt;li&gt;Configure new summary statistics and print them to any text format.&lt;/li&gt;
&lt;li&gt;Stream the results to one or multiple services of your choice (for example, InfluxDB or Prometheus).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;metrics&#34;&gt;Metrics&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Documentation&lt;/strong&gt;: 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/metrics/&#34;&gt;Using metrics&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;k6 comes with built-in metrics about the test load and the system response.
Key metrics include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;http_req_duration&lt;/code&gt;, the end-to-end time of all requests (that is, the total latency)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;http_req_failed&lt;/code&gt;, the total number of failed requests&lt;/li&gt;
&lt;li&gt;&lt;code&gt;iterations&lt;/code&gt;, the total number of iterations&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;end-of-test-summary&#34;&gt;End-of-test summary&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Documentation&lt;/strong&gt;: 
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/end-of-test/&#34;&gt;End-of-test summary&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;By default, k6 prints summarized results to &lt;code&gt;stdout&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;When you run a test, k6 outputs a plain-text logo, your test progress, and some test details.
After the test finishes, k6 prints the full details and summary statistics of the test metrics.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/k6-oss/k6-results-stdout.png&#34;
  alt=&#34;k6 results - console/stdout output&#34; width=&#34;1948&#34;
     height=&#34;1208&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The end-of-test summary shows aggregated statistical values for your result metrics, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Median and average values&lt;/li&gt;
&lt;li&gt;Minimum and maximum values&lt;/li&gt;
&lt;li&gt;p90, p95, and p99 values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can configure the statistics to report with the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/k6-options/reference/#summary-trend-stats&#34;&gt;&lt;code&gt;--summary-trend-stats&lt;/code&gt;&lt;/a&gt; option.
For example, this command displays only median, p95, and p99.9 values.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;sh&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sh&#34;&gt;k6 run --iterations=100 --vus=10 \
--summary-trend-stats=&amp;#34;med,p(95),p(99.9)&amp;#34; script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;custom-reports-with-handlesummary&#34;&gt;Custom reports with &lt;code&gt;handleSummary()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;For completely customized end-of-summary reports, k6 provides the &lt;code&gt;handleSummary()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;At the end of the test, k6 automatically creates an object with all aggregated statistics.
The &lt;code&gt;handleSummary()&lt;/code&gt; function can process this object into a custom report in any text format: JSON, HTML, XML, and whatever else.&lt;/p&gt;
&lt;h2 id=&#34;time-series-and-external-outputs&#34;&gt;Time series and external outputs&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Documentation&lt;/strong&gt;: 
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/&#34;&gt;Real-time metrics&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The condensed end-of-test summary provides a top-level view of the test.
For deeper analysis, you need to look at granular time-series data,
which has metrics and timestamps for every point of the test.&lt;/p&gt;
&lt;p&gt;You can access time-series metrics in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write them to a JSON or CSV file.&lt;/li&gt;
&lt;li&gt;Stream them to an external service.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In both cases, you can use the &lt;code&gt;--out&lt;/code&gt; flag and declare your export format as the flag argument.
If you want to send the metrics to multiple sources, you can use multiple flags with multiple arguments:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;sh&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sh&#34;&gt;k6 run \
--out json=test.json \
--out influxdb=http://localhost:8086/k6&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The available built-in outputs include:&lt;/p&gt;
&lt;Glossary&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/amazon-cloudwatch/&#34;&gt;Amazon CloudWatch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/cloud/&#34;&gt;Cloud&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/csv/&#34;&gt;CSV&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/datadog/&#34;&gt;Datadog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/dynatrace/&#34;&gt;Dynatrace&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/elasticsearch/&#34;&gt;Elasticsearch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/grafana-cloud-prometheus/&#34;&gt;Grafana Cloud Prometheus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/influxdb/&#34;&gt;InfluxDB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/json/&#34;&gt;JSON&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/netdata/&#34;&gt;Netdata&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/new-relic/&#34;&gt;New Relic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/prometheus-remote-write/&#34;&gt;Prometheus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/timescaledb/&#34;&gt;TimescaleDB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/real-time/statsd/&#34;&gt;StatsD&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/Glossary&gt;
]]></content><description>&lt;h1 id="results-output">Results output&lt;/h1>
&lt;p>As k6 generates load for your test, it also makes &lt;em>metrics&lt;/em> that measure the performance of the system.
Broadly, you can analyze metrics in two ways:&lt;/p></description></item><item><title>k6 resources</title><link>https://grafana.com/docs/k6/v2.3.x/get-started/resources/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/get-started/resources/</guid><content><![CDATA[&lt;h1 id=&#34;k6-resources&#34;&gt;k6 resources&lt;/h1&gt;
&lt;p&gt;The docs aim to cover everything necessary to use the core k6 products in your daily operational work.
But scripting and testing are skills that take time to learn.
What&amp;rsquo;s more, k6 is an extensible tool, already incorporated with many other functionalities and protocols.&lt;/p&gt;
&lt;p&gt;These resources help you write and run k6 tests in a safe environment and explore how to use k6 with other applications.&lt;/p&gt;
&lt;h2 id=&#34;learning&#34;&gt;Learning&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/learning-hub/k6-performance-testing/&#34;&gt;Getting started with k6 performance testing&lt;/a&gt;. A Learning Hub course that walks you from your first script to automated baselines with Grafana Cloud.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/learning-paths/run-first-k6-test/&#34;&gt;Run your first k6 performance test&lt;/a&gt;. A hands-on learning path to write, run, and analyze your first test.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/examples/get-started-with-k6/&#34;&gt;Get started with k6 tutorial&lt;/a&gt;. The getting started tutorial provides some procedures for common real-life uses of k6 and does not require prior knowledge of k6 or JavaScript.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/k6-learn&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;k6 Learn&lt;/a&gt;. A repository with a course and a ton of learning resources.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/k6-oss-workshop&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;k6 OSS workshop&lt;/a&gt;. A 2-3 hour k6 workshop with practical k6 examples using the QuickPizza demo app.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.youtube.com/playlist?list=PLDGkOdUX1UjrZM3lIHvFcKJxVgl2n4J65&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;k6 YouTube channel&lt;/a&gt;. Office hours, specific playlists, and other interesting videos from the community.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/awesome-k6&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Awesome k6&lt;/a&gt;. A list of awesome stuff about k6.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/k6/tree/master/examples&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Examples&lt;/a&gt;. A directory full of example k6 scripts for different use cases.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;community&#34;&gt;Community&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://community.grafana.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;The Grafana k6 community forum&lt;/a&gt;. Get support from the k6 team and community.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;test-servers&#34;&gt;Test servers&lt;/h2&gt;
&lt;p&gt;If you need a place to learn k6 and test your scripts, you can use these demo applications:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/quickpizza&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;grafana/quickpizza&lt;/code&gt;&lt;/a&gt;. A demo web application.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;These are testing environments shared by everyone - avoid high-load tests.&lt;/p&gt;
&lt;p&gt;If you want to run tests with high loads, you can deploy and host them on your infrastructure and run the examples in the repository.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;k6--your-favorite-tool&#34;&gt;k6 &#43; your favorite tool&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://k6.io/blog/running-distributed-tests-on-k8s/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Kubernetes Operator&lt;/a&gt;. Distribute test execution across a Kubernetes cluster.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/extensions/&#34;&gt;xk6 extensions&lt;/a&gt;. Custom k6 binaries to support the tool you need.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/javascript-typescript-compatibility-mode/&#34;&gt;Use TypeScript in k6 scripts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/reference/integrations/&#34;&gt;Integrations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="k6-resources">k6 resources&lt;/h1>
&lt;p>The docs aim to cover everything necessary to use the core k6 products in your daily operational work.
But scripting and testing are skills that take time to learn.
What&amp;rsquo;s more, k6 is an extensible tool, already incorporated with many other functionalities and protocols.&lt;/p></description></item><item><title>Migrate to k6 v2</title><link>https://grafana.com/docs/k6/v2.3.x/get-started/migrating-to-v2/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/get-started/migrating-to-v2/</guid><content><![CDATA[&lt;h1 id=&#34;migrate-to-k6-v2&#34;&gt;Migrate to k6 v2&lt;/h1&gt;
&lt;p&gt;This page covers all breaking changes introduced in k6 v2 and the steps to update your scripts, extensions, and configuration.&lt;/p&gt;
&lt;h2 id=&#34;go-module-path-changed-to-gok6iok6v2&#34;&gt;Go module path changed to &lt;code&gt;go.k6.io/k6/v2&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The k6 Go module path has changed from &lt;code&gt;go.k6.io/k6&lt;/code&gt; to &lt;code&gt;go.k6.io/k6/v2&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you maintain a k6 extension, update all import paths in your Go code:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;// Before
import &amp;#34;go.k6.io/k6/js/modules&amp;#34;

// After
import &amp;#34;go.k6.io/k6/v2/js/modules&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Update your &lt;code&gt;go.mod&lt;/code&gt; file and run &lt;code&gt;go mod tidy&lt;/code&gt; after changing the import paths.&lt;/p&gt;
&lt;h2 id=&#34;removed-cli-commands-k6-pause-k6-resume-k6-scale-k6-status&#34;&gt;Removed CLI commands: &lt;code&gt;k6 pause&lt;/code&gt;, &lt;code&gt;k6 resume&lt;/code&gt;, &lt;code&gt;k6 scale&lt;/code&gt;, &lt;code&gt;k6 status&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;pause&lt;/code&gt;, &lt;code&gt;resume&lt;/code&gt;, &lt;code&gt;scale&lt;/code&gt;, and &lt;code&gt;status&lt;/code&gt; top-level CLI commands have been removed. There is no replacement — these commands relied on the &lt;code&gt;externally-controlled&lt;/code&gt; executor, which has also been removed.&lt;/p&gt;
&lt;h2 id=&#34;removed-externally-controlled-executor&#34;&gt;Removed &lt;code&gt;externally-controlled&lt;/code&gt; executor&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;externally-controlled&lt;/code&gt; executor has been removed. There is no replacement. Any test script with &lt;code&gt;executor: externally-controlled&lt;/code&gt; will fail to start. Migrate to a different 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/scenarios/executors/&#34;&gt;executor&lt;/a&gt; based on the desired load profile, for example &lt;code&gt;ramping-vus&lt;/code&gt;, &lt;code&gt;constant-vus&lt;/code&gt;, or &lt;code&gt;constant-arrival-rate&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;removed-cli-command-k6-login&#34;&gt;Removed CLI command: &lt;code&gt;k6 login&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The top-level &lt;code&gt;k6 login&lt;/code&gt; command and its subcommands have been removed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Replace &lt;code&gt;k6 login cloud&lt;/code&gt; with &lt;code&gt;k6 cloud login&lt;/code&gt;. Running it without arguments prompts you interactively for your token and stack:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 cloud login&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;k6 login influxdb&lt;/code&gt; has no replacement command. Configure the InfluxDB output directly using environment variables instead:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;K6_INFLUXDB_ADDR=http://localhost:8086 k6 run --out influxdb script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;stack-is-now-required-for-all-k6-cloud-commands&#34;&gt;Stack is now required for all &lt;code&gt;k6 cloud&lt;/code&gt; commands&lt;/h2&gt;
&lt;p&gt;A Grafana Cloud stack must be provided for all &lt;code&gt;k6 cloud&lt;/code&gt; commands. Run &lt;code&gt;k6 cloud login&lt;/code&gt; once — it prompts interactively for your token and stack:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 cloud login&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For non-interactive environments, pass the values via flags or the &lt;code&gt;K6_CLOUD_STACK_ID&lt;/code&gt; environment variable, or set it in your script using the &lt;code&gt;stackID&lt;/code&gt; option:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;K6_CLOUD_TOKEN=&amp;lt;YOUR_API_TOKEN&amp;gt; K6_CLOUD_STACK_ID=&amp;lt;YOUR_STACK_ID&amp;gt; k6 cloud run script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;cloud-run-non-threshold-aborts-now-exit-with-code-97&#34;&gt;Cloud run non-threshold aborts now exit with code 97&lt;/h2&gt;
&lt;p&gt;Previously, Grafana Cloud k6 runs aborted for reasons other than threshold violations (user abort, system error, timeout, script error) returned exit code &lt;code&gt;0&lt;/code&gt;. They now return exit code &lt;code&gt;97&lt;/code&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Scenario&lt;/th&gt;
              &lt;th&gt;Before&lt;/th&gt;
              &lt;th&gt;After&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Finished&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Aborted by threshold&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;99&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;99&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Aborted by user, system, timeout, or script error&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;97&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Review any CI pipeline logic that treats exit code &lt;code&gt;0&lt;/code&gt; as an unconditional success for &lt;code&gt;k6 cloud run&lt;/code&gt; — those checks now need to handle &lt;code&gt;97&lt;/code&gt; as a distinct failure state.&lt;/p&gt;
&lt;h2 id=&#34;k6-cloud-positional-argument-removed&#34;&gt;&lt;code&gt;k6 cloud&lt;/code&gt; positional argument removed&lt;/h2&gt;
&lt;p&gt;The old positional form &lt;code&gt;k6 cloud script.js&lt;/code&gt; has been removed. Use the explicit subcommand instead:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 cloud run script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;removed---upload-only-flag&#34;&gt;Removed &lt;code&gt;--upload-only&lt;/code&gt; flag&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;--upload-only&lt;/code&gt; flag has been removed. Use the &lt;code&gt;k6 cloud upload&lt;/code&gt; command instead:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 cloud upload script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;removed---no-summary-flag&#34;&gt;Removed &lt;code&gt;--no-summary&lt;/code&gt; flag&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;--no-summary&lt;/code&gt; flag has been removed. Use &lt;code&gt;--summary-mode=disabled&lt;/code&gt; instead:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;# Before
k6 run --no-summary script.js

# After
k6 run --summary-mode=disabled script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;removed---summary-modelegacy&#34;&gt;Removed &lt;code&gt;--summary-mode=legacy&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;legacy&lt;/code&gt; value for &lt;code&gt;--summary-mode&lt;/code&gt; has been removed. The available modes are now &lt;code&gt;compact&lt;/code&gt; (default), &lt;code&gt;full&lt;/code&gt;, and &lt;code&gt;disabled&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;removed-optionsextloadimpact&#34;&gt;Removed &lt;code&gt;options.ext.loadimpact&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;options.ext.loadimpact&lt;/code&gt; configuration block has been removed. Use &lt;code&gt;options.cloud&lt;/code&gt; instead:&lt;/p&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;// Before
export const options = {
  ext: {
    loadimpact: {
      name: &amp;#39;My test name&amp;#39;,
    },
  },
};

// After
export const options = {
  cloud: {
    name: &amp;#39;My test name&amp;#39;,
  },
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;removed-k6experimentalredis&#34;&gt;Removed &lt;code&gt;k6/experimental/redis&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;k6/experimental/redis&lt;/code&gt; module has been removed. Use &lt;code&gt;k6/x/redis&lt;/code&gt; instead:&lt;/p&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;// Before
import { Client } from &amp;#39;k6/experimental/redis&amp;#39;;

// After
import { Client } from &amp;#39;k6/x/redis&amp;#39;;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With 
    &lt;a href=&#34;/docs/k6/v2.3.x/extensions/run/&#34;&gt;automatic extension resolution&lt;/a&gt;, k6 provisions the &lt;code&gt;xk6-redis&lt;/code&gt; extension automatically when it sees the &lt;code&gt;k6/x/redis&lt;/code&gt; import — no manual binary build required.&lt;/p&gt;
&lt;h2 id=&#34;otel-output-k6_otel_exporter_type-renamed-to-k6_otel_exporter_protocol&#34;&gt;OTel output: &lt;code&gt;K6_OTEL_EXPORTER_TYPE&lt;/code&gt; renamed to &lt;code&gt;K6_OTEL_EXPORTER_PROTOCOL&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The accepted values are &lt;code&gt;grpc&lt;/code&gt; and &lt;code&gt;http/protobuf&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;# Before
K6_OTEL_EXPORTER_TYPE=http k6 run --out opentelemetry script.js

# After
K6_OTEL_EXPORTER_PROTOCOL=http/protobuf k6 run --out opentelemetry script.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;otel-output-k6_otel_single_counter_for_rate-removed&#34;&gt;OTel output: &lt;code&gt;K6_OTEL_SINGLE_COUNTER_FOR_RATE&lt;/code&gt; removed&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;K6_OTEL_SINGLE_COUNTER_FOR_RATE&lt;/code&gt; environment variable has been removed. Rate metrics are now always exported as a single counter with a &lt;code&gt;condition&lt;/code&gt; attribute (&lt;code&gt;zero&lt;/code&gt;/&lt;code&gt;nonzero&lt;/code&gt;). If you were using the old pair-of-counters format (&lt;code&gt;metric_name.occurred&lt;/code&gt; / &lt;code&gt;metric_name.total&lt;/code&gt;), update your dashboards and queries to filter on the &lt;code&gt;condition&lt;/code&gt; attribute instead.&lt;/p&gt;
&lt;h2 id=&#34;removed-k6_binary_provisioning&#34;&gt;Removed &lt;code&gt;K6_BINARY_PROVISIONING&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;K6_BINARY_PROVISIONING&lt;/code&gt; environment variable has been removed. Auto-extension resolution is enabled by default. Remove &lt;code&gt;K6_BINARY_PROVISIONING&lt;/code&gt; from your environment. If you need to disable auto-extension resolution, use &lt;code&gt;K6_AUTO_EXTENSION_RESOLUTION=false&lt;/code&gt; instead.&lt;/p&gt;
&lt;h2 id=&#34;removed-k6_enable_community_extensions&#34;&gt;Removed &lt;code&gt;K6_ENABLE_COMMUNITY_EXTENSIONS&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Community extensions no longer require an opt-in flag. Automatic extension resolution works for both official and community extensions by default. Remove any &lt;code&gt;K6_ENABLE_COMMUNITY_EXTENSIONS=true&lt;/code&gt; from your environment.&lt;/p&gt;
&lt;h2 id=&#34;legacy-configuration-file-path-no-longer-migrated&#34;&gt;Legacy configuration file path no longer migrated&lt;/h2&gt;
&lt;p&gt;k6 no longer automatically migrates configuration files from the old &lt;code&gt;{USER_CONFIG_DIR}/loadimpact/config.json&lt;/code&gt; path used before k6 v1.0.0. If you still have a config file at that location, move it manually:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;# Linux / macOS
mv ~/.config/loadimpact/config.json ~/.config/k6/config.json

# Windows
move %APPDATA%\loadimpact\config.json %APPDATA%\k6\config.json&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Alternatively, run &lt;code&gt;k6 cloud login&lt;/code&gt; to regenerate the config at the correct path.&lt;/p&gt;
&lt;h2 id=&#34;browser-browser_web_vital_fid-metric-removed&#34;&gt;Browser: &lt;code&gt;browser_web_vital_fid&lt;/code&gt; metric removed&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;browser_web_vital_fid&lt;/code&gt; metric has been removed as it&amp;rsquo;s &lt;a href=&#34;https://web.dev/articles/fid&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;no longer a Core Web Vital&lt;/a&gt;. Use &lt;code&gt;browser_web_vital_inp&lt;/code&gt; instead, which measures &lt;a href=&#34;https://web.dev/inp/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Interaction to Next Paint&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Update any thresholds that reference &lt;code&gt;browser_web_vital_fid&lt;/code&gt;:&lt;/p&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;// Before
export const options = {
  thresholds: {
    browser_web_vital_fid: [&amp;#39;p(75) &amp;lt; 100&amp;#39;],
  },
};

// After
export const options = {
  thresholds: {
    browser_web_vital_inp: [&amp;#39;p(75) &amp;lt; 200&amp;#39;],
  },
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="migrate-to-k6-v2">Migrate to k6 v2&lt;/h1>
&lt;p>This page covers all breaking changes introduced in k6 v2 and the steps to update your scripts, extensions, and configuration.&lt;/p>
&lt;h2 id="go-module-path-changed-to-gok6iok6v2">Go module path changed to &lt;code>go.k6.io/k6/v2&lt;/code>&lt;/h2>
&lt;p>The k6 Go module path has changed from &lt;code>go.k6.io/k6&lt;/code> to &lt;code>go.k6.io/k6/v2&lt;/code>.&lt;/p></description></item></channel></rss>