• Stars
    star
    278
  • Rank 142,838 (Top 3 %)
  • Language
    HTML
  • License
    GNU Affero Genera...
  • Created almost 3 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A k6 extension that makes k6 metrics available on a web-based dashboard.

Go Report Card GitHub Actions codecov REUSE status

xk6-dashboard

A k6 extension that enables creating a web based metrics dashboard for k6.

By using the xk6-dashboard output extension you can access metrics from k6 process via server-sent events (SSE). All custom k6 metrics (Counter, Gauge, Rate, Trend) and built-in metrics are accessible in the event stream.

The test run report can be exported to a responsive self-contained HTML file, which can be displayed even without an Internet connection.

Screenshots

Overview

The overview tab provides an overview of the most important metrics of the test run. Graphs plot the value of metrics over time.

k6 dashboard overview snapshot

Timings

The timings tab provides an overview of test run HTTP timing metrics. Graphs plot the value of metrics over time.

k6 dashboard timings snapshot

Custom Tab

Example of customizing the display of metrics.

k6 dashboard custom

Summary Tab

The summary tab contains a summary of the test run metrics. The tables contain the aggregated values of the metrics for the entire test run.

k6 dashboard summary

Report

The report tab contains a test run report in a printable (or saveable to PDF) format.

Report Tab k6 dashboard report

Report PDF

See sample PDF report.

HTML Report

The report can be saved in a single responsive HTML file.

Single file HTML report k6 dashboard HTML report

See sample HTML report or try the online version

Table of Contents

Download

You can download pre-built k6 binaries from the Releases page. Check the Packages page for pre-built k6 Docker images.

Build

To build a k6 binary with this extension, first ensure you have the prerequisites:

Then:

  1. Download xk6:
$ go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
$ xk6 build --with github.com/grafana/xk6-dashboard@latest

Usage

Without parameters the dashboard will be accessible on port 5665 with any web browser: http://127.0.0.1:5665

$ ./k6 run --out dashboard script.js

          /\      |‾‾| /‾‾/   /‾‾/   
     /\  /  \     |  |/  /   /  /    
    /  \/    \    |     (   /   ‾‾\  
   /          \   |  |\  \ |  (‾)  | 
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: script.js
     output: dashboard (:5665) http://127.0.0.1:5665

Using --out dashboard=open will automatically open a new browser window.

Exit

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.

In certain environments, it is not allowed that the k6 process does not exit after the test run (eg CI/CD pipeline). In this case, it is advisable to disable the HTTP port (with the -1 value of port parameter).

Parameters

The output extension accepts parameters in a standard query string format:

k6 run --out 'dashboard=param1=value1&param2=value2&param3=value3'

Note the apostrophes (') around the --out parameter! You should use it to escape & characters from the shell (or use backslash before &).

The following parameters are recognized:

parameter description
host Hostname or IP address for HTTP endpoint (default: "", empty, listen on all interfaces)
port TCP port for HTTP endpoint (default: 5665; 0 = random, -1 = no HTTP), example: 8080
period Event emitting frequency (default: 10s), example: 1m
open Set to true (or empty) to open the browser window automatically
report File name to save the report (default: "", empty, the report will not be saved)
record File name to save the dashboard events (default: "", empty, the events will not be saved)
tag Precomputed metric tag name(s) (default: "group"), can be specified more than once

Docker

You can also use pre-built k6 image within a Docker container. In order to do that you will need to execute something like the following:

Linux

docker run -v $(pwd):/scripts -p 5665:5665 -it --rm ghcr.io/grafana/xk6-dashboard:latest run --out=dashboard /scripts/script.js

Windows

docker run -v %cd%:/scripts -p 5665:5665 -it --rm ghcr.io/grafana/xk6-dashboard:latest run --out=dashboard /scripts/script.js

The dashboard will accessible on port 5665 with any web browser: http://127.0.0.1:5665

Save report

The test run report can be exported to a responsive self-contained HTML file. For export, the file name must be specified in the report parameter. If the file name ends with .gz, the HTML report will automatically be gzip compressed.

k6 run --out dashboard=report=test-report.html script.js

The exported HTML report file does not contain external dependencies, so it can be displayed even without an Internet connection. Graphs can be zoomed by selecting a time interval. If necessary, the report can be printed or converted to PDF format.

By using the --report switch of the dashboard replay command, the report can also be generated afterwards from the previously saved JSON format result (--out json=test-result.json).

The report can also be viewed and downloaded from the dashboard UI using the buttons on the "Report" tab.

k6 dashboard replay --report test-report.html test-result.json

Example HTML report k6 dashboard HTML report

See sample HTML report or try the online version

Events

The /events endpoint (default: http://127.0.0.1:5665/events) is a standard SSE source endpoint. Using this event source you can create your own dashboard UI.

Events will be emitted periodically based on the period parameter (default: 10s). The event's data is a JSON object with metric names as property names and metric values as property values. The format is similar to the List Metrics response format from the k6 REST API.

Two kind of events will be emitted:

  • config contains ui configuration
  • param contains main extension parameters (period, scenarios, thresholds, etc)
  • start contains start timestamp
  • stop contains stop timestamp
  • metric contains new metric definitions
  • snapshot contains metric values from last period
  • cumulative contains cumulative metric values from the test starting point

Customization

The embedded user interface can be customized using a single JavaScript configuration file specified in the XK6_DASHBOARD_CONFIG environment variable (default: .dashboard.js in the current directory). The configuration file is an ES6 module. The module's default export is a JavaScript function which returns a configuration object. The default configuration is passed as argument to the exported function.

The default configuration is loaded from the assets/packages/config/dist/config.json file, which can give you ideas for creating your own configuration.

Warning
The format of the custom configuration has changed! The stability of the configuration format is still not guaranteed, so you should check the changes before updating the version. In addition, it is possible that the custom configuration will be limited or phased out in the future.

Examples

Custom tab k6 dashboard custom

In this example, a tab called Custom is defined, which contains six panels and two charts. The first two panels are just a reference to the two panels of the built-in Overview tab.

export default function (config) {
  Array.prototype.getById = function (id) {
    return this.filter(element => element.id == id).at(0)
  }

  // helper for adding p(99) to existing chart
  function addP99 (chart) {
    chart.series = Object.assign({}, chart.series)
    chart.series['http_req_duration.p(99)'] = { label: 'p(99)', format: 'duration' }
  }

  // define request duration panel
  function durationPanel (suffix) {
    return {
      id: `http_req_duration_${suffix}`,
      title: `HTTP Request Duration ${suffix}`,
      metric: `http_req_duration.${suffix}`,
      format: 'duration'
    }
  }
  
  // copy vus and http_reqs panel from default config
  const overview = config.tabs.getById('overview_snapshot')

  // define custom panels
  const customPanels = [
    overview.panels.getById('vus'),
    overview.panels.getById('http_reqs'),
    durationPanel('avg'),
    durationPanel('p(90)'),
    durationPanel('p(95)'),
    durationPanel('p(99)')
  ]

  // copy http_req_duration chart form default config...
  const durationChart = Object.assign({}, overview.charts.getById('http_req_duration'))

  // ... and add p(99)
  addP99(durationChart)

  // define custom tab
  const customTab = {
    id: 'custom',
    title: 'Custom',
    event: overview.event,
    panels: customPanels,
    charts: [overview.charts.getById('http_reqs'), durationChart],
    description: 'Example of customizing the display of metrics.'
  }

  // add custom tab to configuration
  config.tabs.push(customTab)

  return config
}

p(99)

In this example, the 99th percentile value is added to the Request Duration chart on the built-in Overview tabs.

export default function (config) {
  Array.prototype.getById = function (id) {
    return this.filter((element) => element.id == id).at(0);
  };

  // helper for adding p(99) to existing chart
  function addP99(chart) {
    chart.series["http_req_duration.p(99)"] = { label: "p(99)" };
  }

  // add p(99) to overview panels request duration charts
  addP99(config.tabs.getById("overview_snapshot").charts.getById("http_req_duration"));

  return config
}

Command Line

The xk6-dashboard extension adds a dashboard command to the k6 command line:

$ ./k6 dashboard --help

xk6-dashboard commands

Usage:
  k6 dashboard [command]

Available Commands:
  aggregate   convert saved json output to recorded dashboard events
  replay      load the recorded dashboard events and replay it for the UI
  report      create report from a recorded event file  

Flags:
  -h, --help   help for dashboard

Use "k6 dashboard [command] --help" for more information about a command.

At the moment, the dashboard command has three subcommand, replay (which can be used to play back dashboard events previously saved with record parameter), aggregate (which can be used to convert test run results previously saved in JSON format from k6 to dashboard events format NDJSON) and report (which can be used to generate report from dashboard events previously saved with record parameter).

$ ./k6 dashboard replay --help

The replay command load the recorded dashboard events (NDJSON format) and replay it for the dashboard UI.
The compressed file will be automatically decompressed if the file extension is .gz

Usage:
  k6 dashboard replay file [flags]

Flags:
      --host string     Hostname or IP address for HTTP endpoint (default: '', empty, listen on all interfaces)
      --open            Open browser window automatically
      --port int        TCP port for HTTP endpoint (0=random, -1=no HTTP), example: 8080 (default 5665)
      --report string   Report file location (default: '', no report)
  -h, --help            help for replay
$ ./k6 dashboard aggregate --help

The aggregate command converts the file saved by json output to dashboard format events file.
The files will be automatically compressed/decompressed if the file extension is .gz

Usage:
  k6 dashboard aggregate input-file output-file [flags]

Flags:
      --period 1m      Event emitting frequency, example: 1m (default 10s)
      --tags strings   Precomputed metric tags, can be specified more than once (default [group])
  -h, --help           help for aggregate
$ ./k6 dashboard report --help

The report command loads recorded dashboard events (NDJSON format) and creates a report.
The compressed events file will be automatically decompressed if the file extension is .gz

Usage:
  k6 dashboard report events-file report-file [flags]

Flags:
      --open   Open browser window with generated report
  -h, --help   help for report

To visualize the result of a previous test run (using events file):

./k6 run --out dashboard=record=test_result.ndjson script.js
./k6 dashboard replay test_result.ndjson

To visualize the result of a previous test run (using json output):

./k6 run --out json=test_result.json script.js
./k6 dashboard aggregate test_result.json test_result.ndjson
./k6 dashboard replay test_result.ndjson

To generate report from previous test run (using events file):

./k6 run --out dashboard=record=test_result.ndjson script.js
./k6 dashboard report test_result.ndjson test_result_report.html

Docker

You can also use pre-built k6 image within a Docker container. In order to do that, you will need to execute something like the following:

Linux

docker run -v $(pwd):/work -v /tmp:/tmp/work -it --rm ghcr.io/grafana/xk6-dashboard:latest run --out=json=/tmp/work/test_result.json.gz /work/script.js
docker run -v /tmp:/tmp/work -p 5665:5665 -it --rm ghcr.io/grafana/xk6-dashboard:latest dashboard replay /tmp/work/test_result.json.gz

Windows

docker run -v %cd%:/work -v %USERPROFILE%\AppData\Local\Temp:/tmp/work -it --rm ghcr.io/grafana/xk6-dashboard:latest run --out=json=/tmp/work/test_result.json.gz /work/script.js
docker run -v %USERPROFILE%\AppData\Local\Temp:/tmp/work -p 5665:5665 -it --rm ghcr.io/grafana/xk6-dashboard:latest dashboard replay /tmp/work/test_result.json.gz

The dashboard will accessible on port 5665 with any web browser: http://127.0.0.1:5665

More Repositories

1

grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
TypeScript
60,280
star
2

k6

A modern load testing tool, using Go and JavaScript - https://k6.io
Go
22,905
star
3

loki

Like Prometheus, but for logs.
Go
22,069
star
4

pyroscope

Continuous Profiling Platform. Debug performance issues down to a single line of code
C
9,361
star
5

mimir

Grafana Mimir provides horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.
Go
3,634
star
6

tempo

Grafana Tempo is a high volume, minimal dependency distributed tracing backend.
Go
3,561
star
7

oncall

Developer-friendly incident response with brilliant Slack integration
Python
3,223
star
8

tanka

Flexible, reusable and concise configuration for Kubernetes
Go
2,235
star
9

phlare

🔥 horizontally-scalable, highly-available, multi-tenant continuous profiling aggregation system
Go
2,059
star
10

grafana-zabbix

Zabbix plugin for Grafana dashboard
TypeScript
2,020
star
11

agent

Vendor-neutral programmable observability pipelines.
Go
1,544
star
12

helm-charts

Smarty
1,494
star
13

grafonnet-lib

Jsonnet library for generating Grafana dashboard files.
Jsonnet
1,079
star
14

beyla

eBPF-based autoinstrumentation of HTTP and HTTPS services
C
1,032
star
15

grafana-operator

An operator for Grafana that installs and manages Grafana instances, Dashboards and Datasources through Kubernetes/OpenShift CRs
Go
756
star
16

alloy

OpenTelemetry Collector distribution with programmable pipelines
Go
711
star
17

grafana-docker

Grafana docker container
Shell
638
star
18

metrictank

metrics2.0 based, multi-tenant timeseries store for Graphite and friends.
Go
623
star
19

faro-web-sdk

The Grafana Faro Web SDK, part of the Grafana Faro project, is a highly configurable web SDK for real user monitoring (RUM) that instruments browser frontend applications to capture observability signals. Frontend telemetry can then be correlated with backend and infrastructure data for full-stack observability.
TypeScript
623
star
20

grafana-infinity-datasource

CSV, JSON, GraphQL, XML and HTML datasource for grafana.
TypeScript
591
star
21

jsonnet-libs

Grafana Labs' Jsonnet libraries
Jsonnet
516
star
22

k6-operator

An operator for running distributed k6 tests.
Go
506
star
23

simple-json-datasource

Datasource that sends generic http requests to give url
JavaScript
502
star
24

awesome-k6

A curated list of awesome tools, content and projects using k6
493
star
25

carbon-relay-ng

Fast carbon relay+aggregator with admin interfaces for making changes online - production ready
Go
455
star
26

grizzly

A utility for managing Jsonnet dashboards against the Grafana API
Go
424
star
27

terraform-provider-grafana

Terraform Grafana provider
Go
391
star
28

grafana-image-renderer

A Grafana backend plugin that handles rendering of panels & dashboards to PNGs using headless browser (Chromium/Chrome)
TypeScript
335
star
29

dskit

Distributed systems kit
Go
316
star
30

grafana-kiosk

Kiosk Utility for Grafana
Go
314
star
31

xk6-browser

k6 extension that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol
Go
310
star
32

worldmap-panel

Worldmap panel plugin for Grafana 3.0 that can be overlaid with circles for data points.
JavaScript
301
star
33

postman-to-k6

Converts Postman collections to k6 script code
JavaScript
286
star
34

grafana-json-datasource

A data source plugin for loading JSON APIs into Grafana.
TypeScript
261
star
35

k6-learn

JavaScript
255
star
36

k6-template-typescript

Template to use TypeScript with k6
TypeScript
250
star
37

grafonnet

Jsonnet library for generating Grafana dashboards.
Jsonnet
229
star
38

dashboard-linter

A tool to lint Grafana dashboards
Go
187
star
39

thema

A CUE-based framework for portable, evolvable schema
Go
185
star
40

tns

Observability Demo App
Jsonnet
185
star
41

intro-to-mltp

Introduction to Metrics, Logs, Traces and Profiles session companion code.
JavaScript
181
star
42

strava-datasource

Strava datasource for Grafana dashboard
TypeScript
171
star
43

xk6

Build k6 with extensions
Go
169
star
44

github-datasource

Grafana data source plugin using the Github API to retrieve and visualize Github data.
Go
169
star
45

grafana-plugin-sdk-go

A Go SDK for building backend plugins for Grafana
Go
165
star
46

jsonnet-language-server

A Language Server Protocol (LSP) server for Jsonnet (https://jsonnet.org)
Go
154
star
47

grafana-plugin-examples

Shell
152
star
48

django-saml2-auth

Django SAML2 Authentication Made Easy. Easily integrate with SAML2 SSO identity providers like Okta, Azure AD and others.
Python
151
star
49

cortex-tools

If you're using this tool with Grafana Mimir, please switch to "mimirtool" instead: https://github.com/grafana/mimir
Go
150
star
50

piechart-panel

Pie Chart Panel Plugin
JavaScript
150
star
51

grafana-plugin-repository

The plugin repository for plugins that are published on grafana.com.
JavaScript
147
star
52

mqtt-datasource

MQTT Datasource for Grafana allows streaming data from any MQTT broker running either locally or remotely.
Go
143
star
53

xk6-output-prometheus-remote

k6 extension to output real-time test metrics using Prometheus Remote Write.
Go
139
star
54

scribe

A tool for building elaborate CI pipelines using a familiar programming language
Go
124
star
55

kubernetes-diff-logger

Logs updates to Kubernetes Objects for storing and querying with Loki
Go
122
star
56

pyroscope-rs

Pyroscope Profiler for Rust. Profile your Rust applications.
Rust
119
star
57

synthetic-monitoring-agent

Synthetic Monitoring Agent
Go
118
star
58

har-to-k6

JSON config representation of K6 script
JavaScript
114
star
59

scenes

Build Grafana dashboards directly in your Grafana app plugins.
TypeScript
114
star
60

faro

Grafana Faro is a project for frontend application observability. It includes a highly configurable web SDK that instruments browser frontend applications to capture observability signals.
113
star
61

google-sheets-datasource

Load Google Sheets in grafana
Go
112
star
62

tutorials

A series of tutorials for helping you make the most out of Grafana.
Makefile
109
star
63

synthetic-monitoring-app

Synthetic Monitoring frontend application
TypeScript
107
star
64

grafana-api-golang-client

Grafana HTTP API Client for Go
Go
105
star
65

k6-action

k6 is now available as a GitHub Action
JavaScript
101
star
66

clickhouse-datasource

Grafana Plugin for ClickHouse
TypeScript
101
star
67

k8s-monitoring-helm

Shell
96
star
68

cuetsy

Experimental CUE->TypeScript exporter
Go
96
star
69

rollout-operator

Kubernetes Rollout Operator
Go
96
star
70

azure-monitor-datasource

Grafana data source for Azure Monitor/Application Insights (deprecated - now included in core Grafana)
TypeScript
92
star
71

dashboard-spec

Go
91
star
72

clock-panel

Clock Panel Plugin for Grafana
TypeScript
88
star
73

grafana-polystat-panel

D3-Based hexagon layout multi-stat panel
TypeScript
86
star
74

docker-otel-lgtm

Dockerfile
82
star
75

k6-docs

The k6 documentation website.
JavaScript
80
star
76

xk6-disruptor

Extension for injecting faults into k6 tests
Go
80
star
77

k6-template-es6

Template using Webpack and Babel to enable ES6 features in k6 tests
JavaScript
77
star
78

cortex-jsonnet

Deprecated: see https://github.com/grafana/mimir/tree/main/operations/mimir instead
Jsonnet
74
star
79

doom-datasource

Hackathon project
C
71
star
80

tutorial-environment

Environment for tutorial excercises
Go
70
star
81

pyroscope-go

This is the golang client integration for Pyroscope
Go
69
star
82

grafana-ansible-collection

grafana.grafana Ansible collection provides modules and roles for managing various resources on Grafana Cloud and roles to manage and deploy Grafana Agent and Grafana
Python
69
star
83

database-migrator

Code to export grafana.db (sqlite) to MySQL-compatible SQL file, to assist in migration of Grafana data to MySQL-compatible DB.
Shell
67
star
84

grafana-csv-datasource

A data source for loading CSV data into Grafana.
TypeScript
67
star
85

mimir-proxies

Proxies to help you ingest your metrics into Grafana Mimir.
Go
65
star
86

pyroscope-java

pyroscope java integration
Java
65
star
87

otel-profiling-go

Open Telemetry integration for Grafana Pyroscope and tracing solutions such as Grafana Tempo, Honeycomb, or Jaeger
Go
65
star
88

memo

easily save grafana annotations from slack mentions and the cli
Go
65
star
89

JPProf

Go Pprof but for Java runtime.
Java
65
star
90

grafana-starter-panel

A starter for Grafana panel plugins
TypeScript
65
star
91

xk6-sql

k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)
Go
64
star
92

vscode-jsonnet

Full code support (formatting, highlighting, navigation, etc) for Jsonnet
JavaScript
64
star
93

jmeter-to-k6

Converts JMeter .jmx files to k6 JS code
JavaScript
63
star
94

xk6-distributed-tracing

A k6 extension for distributed tracing.
Go
62
star
95

github-to-es

GitHub Analytics With Elasticsearch And Grafana
JavaScript
54
star
96

opcua-datasource

An OPC UA datasource for reading from OPC UA servers (DA/HDA/AE) into Grafana directly
CSS
54
star
97

grafana-plugin-sdk-rust

Grafana Plugin SDK for Rust
Rust
53
star
98

xk6-kubernetes

Client extension for interacting with Kubernetes clusters from your k6 tests.
Go
52
star
99

regexp

Faster version of the Go regexp package
Go
51
star
100

influxdb-flux-datasource

Grafana datasource plugin for Flux (InfluxDB)
Go
51
star