Request Fail rate

Hi guys

I wanted a little insight on something. For most of the spike tests I try to run I always end up with a lot of requests failing. I was curious if there was a method to use to figure out why that is. Either some kind of command or maybe something I am not doing right on my end

Hi @halshere !

Unfortunately, out of the box there is no method to get the details of the errors.

However, you could use the workaround with check in your script and log failed responses to find what caused them, for instance:

import http from 'k6/http';
import { check, fail } from 'k6';

export default function () {
  const res = http.get('http://httpbin.test.k6.io');
  const checkOutput = check(
    res,
    {
      'response code was 200': (res) => res.status == 200,
      'body size was 1234 bytes': (res) => res.body.length == 1234,
    },
    { myTag: "I'm a tag" }
  );

  if (!checkOutput) {
    console.log('unexpected response')
    console.log(res)
  }
}

Let me know if that answers,
Cheers!

thank you for your response @olegbespalov !

so what im getting from this is that checks will help me figure out what is going wrong but k6 doesn’t have its own diagnosis method? i.e. in my screenshot above I have a check for 200 code but k6 cant find out what is causing it?

I have a lot of timeout response in my terminal when running my spike tests even though I set the timeout time 2 minutes instead if the default 1 minute

im sorry if all this sounds complicated, I am thinking while I type

Hey @halshere !

Not sure if I got your question right, but let me try to answer it.

The thing is that this failure is happening on the server that you’re trying to test, and k6 says it was expected HTTP Status 200 but got something else (maybe it’s an error, but maybe not 429 Too Many Requests). So it’s hard to have a general diagnosis method.

The honest answer why is, in any case, probably in logs of the server/LB or whatever, but k6 acts here just as an external customer and has no access to the internals of your system under test.

However, k6 also has the power of scripting, and you can use it to write the logic that will help you to identify the root cause.

Let me know if that helps.
Cheers!

@olegbespalov that helps a lot. Thank you for the fast responses!

1 Like