Invalid threshold error

level=error msg=“invalid threshold defined on failed requests; reason: no metric name “failed requests” found”

I’m getting this error now for my simple login script. The test has been working fine just 3 days ago, but now getting the above error. – downloading the latest version when docker builds the image.

Hi @generalChicken,
welcome to the community forum. :tada:

The new k6 version contains a validation for thresholds. You can read the details from the release notes.

Can you post your script without the sensible data or at least the part for the thresholds definition, please? It should be easier for us to support you.

I got it working – the fix was to use the defined metrics. Thresholds
I did review the latest release (v0.38.1) and understood the issue.

Changing it to
“failed request” → “http_req_failed”

  "http_req_duration": ["p(90)<5000"],
  **"http_req_failed": ["rate<0.1"],**. --- renaming it to "http_req_failed"

after this change it fixed both locally and via cicd

Yeah, old k6 releases didn’t validate that thresholds were defined for valid metrics. They just silently ignored them, which could lead to a false sense of security (e.g. someone thinking that their system is performing well).

We hope there won’t be a lot of scripts like yours that are going to fail, but we thought it was better for everyone to correct errors like this, since warnings in the CLI might be ignored if the test is executed in a CI environment or something like that :man_shrugging: