Hi
How can i add custom metrics for k6 other than (Trend, Rate, Counter, or Gauge)? What i am looking for is showing the full response body of the failed request rather than just the status
HI @bilal,
This won’t really be a metric … I don’t even know what you will do with such a metric … as I don’t know of any of the current outputs supporting anything apart from the 4 types that you listed
If this is for debugging purposes I would recommend using console.log
as in
let res = http.get(url);
console.log(res.body);
Maybe a little bit more about what you are trying to do will help us find a suitable workaround
Thanks for your response. Console.log will work fine in my local box, but I want to be able to see the error in the response in LoadImpact portal rather than just 500, so i know why the request failed
Hi, sorry for the slow reply, needed to do some consulting
So we do have the console.log
being visible in the cloud on the roadmap with a shaky target of 2020Q1.
There also turned out to be proposals to specifically store “failed” responses so that they can be examined but this has only been brainstormed on .
Up until then I have two possible workarounds both of them not great :
- Add more return status other than 500 explaining the different things that happened … this obviously might not be possible for everything especially if the things returning the status code is not under your control
- Run some software to store your bodies in. Something that just takes posts and stores them in a database/disk will be perfectly good (mongodb apparently has a couple of REST api frontends , for example). And than when you get a 500 in k6 than you don’t know what it’s about post it to that service. It will work with loadimpact as well.
The second approach apart from having to run another service (with some authentication in front of it ) also has the unfortunate sideeffect of skewing results as you will be making requests to report your failures … I don’t know how relevant this is for your case though