Threshold on a group duration does nothing, Threshold on a group duration section

I have run exactly the same script as described in the documentation and noticed that test never fails even when group duration exceeds the threshold. It seems that group duration isn’t collected. Probably, some info is missed in documentation.

an example of the run

Hi @MaksymCode

you are right. This example wasn’t working as expected in the cloud. Thank you for pointing it out. We have now removed it from the documentation.
I added the feature of creating thresholds on groups to the roadmap. We will try to implement this in the next few weeks.

It turns out that it’s very simple to create a custom metric for tracking group duration that works locally and in the cloud. Please see the script below.

import http from "k6/http";
import { group } from "k6";
import { sleep } from 'k6';
import { Trend } from 'k6/metrics';

let groupDuration = Trend("groupDuration");

export let options = {
  thresholds: {
    'groupDuration{groupName:individualRequests}': ['avg < 200'],
    'groupDuration{groupName:batchRequests}': ['avg < 200'],
  vus: 1,
  duration: '10s'

function groupWithDurationMetric(name, group_function) {
  let start = new Date();
  group(name, group_function);
  let end = new Date();
  groupDuration.add(end - start, {groupName: name})

export default function () {

  groupWithDurationMetric("individualRequests", function () {

  groupWithDurationMetric("batchRequests", function () {
      ['GET', ``],
      ['GET', ``],
      ['GET', ``],


Here’s how it looks for local execution:

And here’s a sample cloud run:

Hope this helps!

Hi @pawel,
thank you for a working example