k6 community forum

No "count" display on the group metrics

Any suggestion why “count” does not display on the cli summary?

const t01_trend = new Trend(“T01_launch”);

thresholds: {
summaryTrendStats: [“min”, “max”, “avg”, “p(90)”, “p(95)”, “p(99)”, “count”]

In summary cli
T01_launch…: min=21.531 max=21.531 avg=21.531 p(90)=21.531 p(95)=21.531 p(99)=21.531

Referring to this commit, it should be able to support the count option.


that feature isn’t publicly released yet, though it will be part of the upcoming v0.26.0 release, planned for this week. Keep a lookout at the releases page, though in the meantime you can compile and use k6 master, where this should work.

Also note to follow only the official https://github.com/loadimpact/k6 repository, as 3rd-party forks might not be up to date and are not officially supported.

Also, you’ve tried to define the summaryTrendStats option inside of thresholds, but it is a global option. Here’s a complete script that demonstrates it:

import http from "k6/http";
import { Trend } from "k6/metrics";

const totalDuration = new Trend("total_duration", true);

export let options = {
    iterations: 5,
    summaryTrendStats: ["min", "max", "avg", "p(90)", "p(95)", "p(99)", "count"],

export default function () {
    let responses = http.batch([
        ["GET", "https://test.loadimpact.com/"],
        ["GET", "https://test.loadimpact.com/style.css"],
        ["GET", "https://test.loadimpact.com/images/logo.png"]

    totalDuration.add(responses.reduce((acc, resp) => acc + resp.timings.duration, 0));

With the latest k6 master (either compiled yourself, or using the Docker master image tag), you’d get something like this:

    duration: -,  iterations: 5
         vus: 1, max: 1

    done [==========================================================] 5 / 5

    data_received..............: 43 kB  37 kB/s
    data_sent..................: 2.8 kB 2.4 kB/s
    http_req_blocked...........: min=1.41µs   max=473.47ms avg=63.13ms  p(90)=284.08ms p(95)=473.47ms p(99)=473.47ms count=15
    http_req_connecting........: min=0s       max=138.97ms avg=9.26ms   p(90)=0s       p(95)=41.69ms  p(99)=119.51ms count=15
    http_req_duration..........: min=137.89ms max=140.9ms  avg=139.47ms p(90)=140.53ms p(95)=140.69ms p(99)=140.85ms count=15
    http_req_receiving.........: min=52.73µs  max=312µs    avg=126.61µs p(90)=232.36µs p(95)=290.89µs p(99)=307.78µs count=15
    http_req_sending...........: min=10.52µs  max=210.84µs avg=39.99µs  p(90)=59.26µs  p(95)=113.56µs p(99)=191.38µs count=15
    http_req_tls_handshaking...: min=0s       max=330.2ms  avg=22.01ms  p(90)=0s       p(95)=99.06ms  p(99)=283.97ms count=15
    http_req_waiting...........: min=137.66ms max=140.78ms avg=139.3ms  p(90)=140.31ms p(95)=140.47ms p(99)=140.72ms count=15
    http_reqs..................: 15     12.782741/s
    iteration_duration.........: min=138.27ms max=614.51ms avg=234.8ms  p(90)=425.14ms p(95)=519.83ms p(99)=595.57ms count=5 
    iterations.................: 5      4.260914/s
    total_duration.............: min=413.85ms max=421.41ms avg=418.41ms p(90)=420.78ms p(95)=421.1ms  p(99)=421.35ms count=5 
    vus........................: 1      min=1 max=1
    vus_max....................: 1      min=1 max=1

thanks @imiric. I will take note release note in future.

I have encountered error below:-
ERRO[0001] TypeError: Object has no member ‘reduce’

is this option available at the latest build v0.25.1?

My mistake, i just realised v0.26.0 is available to use now. The code is working perfectly fine.
However, do you have any example of just with http.get/http.post?

One more question, possible to configure the count only store the HTTP200 response time / pass through the check() function.

Or even position to track the number of pass count / number of fail count?

One more question, possible to configure the count only store the HTTP200 response time / pass through the check() function.
Or even position to track the number of pass count / number of fail count?

I don’t understand your question, sorry.

Let say I have 1 VU with a total of 5 iteration test execution.

3 out of 5 returned HTTP200
2 out of 5 returned HTTP502

Based on the current result display on stdout, no matter pass or fail transaction will be consolidated into a single group. The count value will be 5.

However, I would like to see the test result only consolidate the pass transaction, and also indicate the number of fail transaction.

min |max |avg |pass trans |fail trans
x |x |x |3 |2

I’m still not sure I fully understand your question, but you should be able to achieve what you want with a combination of custom Trend (https://docs.k6.io/docs/trend-k6metrics) and Count (https://docs.k6.io/docs/counter-k6metrics) metrics and if statements based on the response.status value (https://docs.k6.io/docs/response-k6http), right?

Yeah, I got your idea. Currently I am using custom metrics (rate) to track the total transaction. TQVM.