Custom Metrics and Trends in k6
Define your own Counter, Gauge, Rate, and Trend metrics in k6 to measure exactly what matters for your advanced scenarios.
Beyond Built-in Metrics
k6 ships with built-in metrics like http_req_duration, but advanced tests often need to measure domain-specific values: items in a cart, business transaction time, or a custom error rate. k6 lets you create custom metrics.
The Four Metric Types
k6 offers four custom metric types from k6/metrics:
- Counter — cumulative sum.
- Gauge — last recorded value.
- Rate — percentage of non-zero/true values.
- Trend — statistics like min, max, avg, p95.
All lessons in this course
- Virtual User Scenarios (VUs)
- Data Parameterization in k6
- Cloud Execution with k6
- Custom Metrics and Trends in k6