Threshold status after the test


how can I access the threshold status right after the test? I would like to make an API call based on the threshold status.

import http from 'k6/http';
import { sleep } from 'k6';

export const options = {
  thresholds: {
    http_req_duration: ['p(95)<250'],

export default function () {

export function handleSummary() {
  if (threshold.status == 'OK') {
  return 'stuff'

In the above example I would like to know how to “access” threshold status and what kind of responses can I get?

For this example, the solution would be:

export function handleSummary(data) {

If you need to view or work with the format of the end-of-test summary, you can log the output like:

export function handleSummary(data) {

  return { 'raw-data.json': JSON.parse(data)};


You can take a quick look at the output format on the handleSummary docs.

You can also use or see - a module to process the summary data and output it to various formats.

thank you for the answer. I managed to figure out something similar:

function CheckThresholds(data, metric) {
    const res = data['metrics'][metric]['thresholds'] ? data['metrics'][metric]['thresholds'] : true
    return Object.values(res).every(obj => obj['ok'])

it covers all thresholds within a chosen metric, and if at least one is false we get false. :slight_smile: if all true we get true

thx to above I can send some API calls to testrail and report the results during the test.