Skip to content
Tutorials Center
My learning

Topics

Lesson 24 of 36 ยท Results and Metrics

k6 Built-in Metrics Explained

Learn every important k6 built-in metric, the four metric types (counter, gauge, rate, trend), how percentiles work, and how to read the end-of-test table without being misled.

When a k6 test finishes it prints a table of numbers. Those numbers are metrics: named streams of measurements that k6 collects during the run. Reading them correctly is half of load testing. A p(95) that looks fine can hide a failing endpoint; an average can hide a long tail. This lesson explains what each built-in metric means and how its type decides how it is summarized.

Honesty note. k6 cannot run on this site. The k6 output below is read-only and illustrative. The runnable blocks are Node stand-ins that compute the same kinds of statistics (counter, gauge, rate, trend, percentiles) from simulated measurements, so you can see how the maths works.

The four metric types

Type What it holds Summary shows Example
Counter A value that only grows Total and per-second rate http_reqs, data_sent
Gauge The latest value Last, min, max vus, vus_max
Rate Share of non-zero values A percentage http_req_failed, checks
Trend A distribution of values avg, min, med, max, p(90), p(95) http_req_duration, iteration_duration

Knowing the type tells you which aggregation you can use in a threshold: counters support count and rate; gauges value; rates rate; trends avg, min, max, med, p(N).

HTTP metrics

Every request made with k6/http records these:

Metric Type Meaning
http_reqs Counter Total requests (also gives requests per second)
http_req_failed Rate Share of failed requests (non-expected status or transport error)
http_req_duration Trend Total time: sending + waiting + receiving
http_req_blocked Trend Waiting for a free connection
http_req_connecting Trend TCP connect time
http_req_tls_handshaking Trend TLS handshake time
http_req_sending Trend Time sending data
http_req_waiting Trend Time to first byte
http_req_receiving Trend Time receiving the response

General metrics

Metric Type Meaning
vus Gauge Currently active virtual users
vus_max Gauge Allocated VUs (capacity)
iterations Counter Completed runs of the default function
iteration_duration Trend Time for a full iteration, including sleep()
dropped_iterations Counter Iterations k6 could not start in time (arrival-rate executors)
data_sent, data_received Counter Bytes transferred
checks Rate Share of check() calls that passed

The dashed relation worth memorizing: http_req_duration = http_req_sending + http_req_waiting + http_req_receiving. It excludes connection setup (blocked, connecting, tls_handshaking).

A real end-of-test summary (read-only, abbreviated) looks like this:

TEXT
     checks.........................: 99.20% 1190 out of 1200
     data_received..................: 18 MB  300 kB/s
     http_req_duration..............: avg=121.4ms min=31ms med=98ms max=1.9s p(90)=210ms p(95)=310ms
     http_req_failed................: 0.80%  10 out of 1200
     http_reqs......................: 1200   20/s
     iteration_duration.............: avg=1.12s min=1.03s med=1.1s max=3.1s p(90)=1.2s p(95)=1.3s
     vus............................: 1      min=1  max=50

Why percentiles beat averages

An average mixes fast and slow requests into one comfortable number. A percentile says "this share of requests were at least this fast". p(95) = 310 ms means 95 % of requests finished within 310 ms and 5 % took longer. For a user-facing system look at p(95) and p(99): the slowest requests belong to real people, and a user who makes 20 requests per visit will meet a p(95) request on most visits.

Node.js Stand-in: counter, gauge, rate and trend from simulated requests

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Reading a result: three habits

  1. Look at the shape, not one number. Compare med, p(95) and max. A median of 98 ms with a max of 1.9 s means a long tail worth investigating.
  2. Always read http_req_failed and checks first. Fast responses are worthless if they are all errors. A 500 error returns quickly, which can improve your latency numbers while the system burns.
  3. Remember what is and is not included. iteration_duration includes your sleep() calls; http_req_duration does not include connection setup.

Dropped iterations and saturation

With arrival-rate executors (covered in chapter 4), k6 tries to start a fixed number of iterations per second. If your VUs are all busy because the server slowed down, k6 cannot start new iterations on time and records dropped_iterations. A non-zero value means the target load was not delivered: either the system is saturated or you did not allow enough maxVUs. Treat it as a result, not noise.

Peeking at metrics inside the script

You cannot read the live value of a built-in metric in the script, but each response carries its own numbers, and you can feed them to your own metrics (next lesson):

JavaScript
import http from 'k6/http';

export default function () {
  const res = http.get('https://shop.example.test/');
  console.log(res.timings.waiting, res.timings.duration);
}
Node.js Stand-in: p(95) per endpoint reveals a slow route

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

The second example is exactly why Tags and groups matter: one combined http_req_duration can look healthy while one route is slow.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which metric type is http_req_failed?

    http_req_failed is a Rate: the share of requests that failed, shown as a percentage.
  2. 2. What is http_req_duration made of?

    It is sending + waiting + receiving, and excludes connection setup time.
  3. 3. A run shows p(95)=300ms for http_req_duration. What does that mean?

    A percentile describes the distribution: 95 percent of values are at or below it.
  4. 4. What does a non-zero dropped_iterations tell you?

    It signals that VUs were all busy (the system slowed down) or that maxVUs was too small for the arrival rate.

Summary

  • Metrics come in four types: counter, gauge, rate and trend; the type limits the aggregations you can use.
  • Key HTTP metrics: http_reqs, http_req_failed, http_req_duration and its parts.
  • Prefer percentiles over averages, and read failures before latency.
  • dropped_iterations means the planned load was not delivered.

Next: Sub-metrics, Cardinality and Per-Route Results