|
| 1 | +--- |
| 2 | +title: Web dashboard |
| 3 | +description: Track test results in real-time with the web-dashboard and generate HTML test reports directly from your web browser. |
| 4 | +weight: 200 |
| 5 | +--- |
| 6 | + |
| 7 | +# Web dashboard |
| 8 | + |
| 9 | +k6 provides a built-in web dashboard that you can enable to visualize and monitor your tests results in real-time. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +The dashboard provides a real-time overview of the performance observed by k6 while a test is running, and can help you identify potential reliability issues as they occur. |
| 14 | + |
| 15 | +## How to use |
| 16 | + |
| 17 | +The web dashboard is a built-in feature of k6. You can enable it by setting the `K6_WEB_DASHBOARD` environment variable to `true` when running your test script, for example: |
| 18 | + |
| 19 | +```shell |
| 20 | +K6_WEB_DASHBOARD=true k6 run script.js |
| 21 | +``` |
| 22 | + |
| 23 | +```shell |
| 24 | +K6_WEB_DASHBOARD=true ./k6 run script.js |
| 25 | + |
| 26 | + /\ |‾‾| /‾‾/ /‾‾/ |
| 27 | + /\ / \ | |/ / / / |
| 28 | + / \/ \ | ( / ‾‾\ |
| 29 | + / \ | |\ \ | (‾) | |
| 30 | + / __________ \ |__| \__\ \_____/ .io |
| 31 | + |
| 32 | + execution: local |
| 33 | + script: ../extensions/xk6-dashboard/script.js |
| 34 | + web dashboard: http://127.0.0.1:5665 |
| 35 | + output: - |
| 36 | +``` |
| 37 | +
|
| 38 | +By default, the web dashboard is available on localhost port `5665`. You can change the host and port by using the [dashboard options](#dashboard-options). |
| 39 | +
|
| 40 | +{{% admonition type="note" %}} |
| 41 | +
|
| 42 | +The k6 process waits to exit as long as there is at least one open browser window for the dashboard extension. In this way, the report can be downloaded, for example, even after the test has been completed. |
| 43 | +
|
| 44 | +In certain environments, it is not allowed that the k6 process does not exit after the test run (_e.g_ CI/CD pipeline). In this case, it is advisable to disable the HTTP port (with the `-1` value of port parameter). |
| 45 | +
|
| 46 | +{{% /admonition %}} |
| 47 | +
|
| 48 | +## Generate HTML test reports |
| 49 | +
|
| 50 | +You can generate detailed, downloadable HTML reports directly from the web dashboard or the command line. These reports are self-contained, making them ideal for sharing with your team. |
| 51 | +
|
| 52 | + |
| 53 | +
|
| 54 | +### Generate report from web dashboard |
| 55 | +
|
| 56 | +To generate a report from the web dashboard, click **Report** on the dashboard's menu. |
| 57 | +
|
| 58 | + |
| 59 | +
|
| 60 | +### Generate report from the command line |
| 61 | +
|
| 62 | +To automatically generate a report from the command line once the test finishes running, use the `K6_WEB_DASHBOARD_EXPORT` option. For example: |
| 63 | +
|
| 64 | +```shell |
| 65 | +K6_WEB_DASHBOARD=true K6_WEB_DASHBOARD_EXPORT=html-report.html k6 run script.js |
| 66 | +``` |
| 67 | +
|
| 68 | +## Dashboard options |
| 69 | +
|
| 70 | +The web dashboard can be configured using environment variables: |
| 71 | +
|
| 72 | +| Environment variable | Description | Default value | |
| 73 | +| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | |
| 74 | +| `K6_WEB_DASHBOARD` | Enable the web dashboard | `false` | |
| 75 | +| `K6_WEB_DASHBOARD_HOST` | Host to bind the web dashboard to | `localhost` | |
| 76 | +| `K6_WEB_DASHBOARD_PORT` | Port to bind the web dashboard to | `5665` | |
| 77 | +| `K6_WEB_DASHBOARD_PERIOD` | Period in seconds to update the web dashboard | `10s` | |
| 78 | +| `K6_WEB_DASHBOARD_OPEN` | Open the web dashboard in the default browser | `false` | |
| 79 | +| `K6_WEB_DASHBOARD_EXPORT ` | Filename to automatically export the HTML test report to at the end of the test run. By default, the value is empty and the report isn't exported. | `` | |
0 commit comments