I am trying to understand what the web dashboard in k6 shows and what it means. I am having trouble understanding the failure rate metric.
I have the following script:
import { check } from 'k6';
import http from 'k6/http';
import { Counter } from 'k6/metrics';
export const options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'ramping-arrival-rate',
// Start iterations per `timeUnit`
startRate: 5,
// Start `startRate` iterations per minute
timeUnit: '1s',
// Pre-allocate necessary VUs.
preAllocatedVUs: 50,
stages: [
{ target: 5, duration: '10s' },
{ target: 500, duration: '5m' },
],
},
},
};
const non200 = new Counter('non_200_responses');
export default () => {
const res = http.get('http://localhost:8000/customers');
if (res.status !== 200) {
non200.add(1);
}
};
I fully shut down my server and ran the script above. I would expect that the Request rate should equal the Request failed. The request rate is as expected, maxing out at 500rps but the request failed is constant at 1rps. Is this a bug or should I set things up different? Since the server was not even running I would expect that the request rate and failed rate should be equal.
I had similar results when the server was running and I was sending 500 status code on every request. And I had the same thing regardless of whether I had a check or not or whether I set up http.setResponseCallback(http.expectedStatuses(200));
Hello @olevski90,
Welcome to our community! ![:tada: :tada:](https://emoji.discourse-cdn.com/twitter/tada.png?v=12)
After taking a look at how xk6-dashboard works (my first time diving into that codebase), I realized that the source of your confusion (it is really confusing!) is the combination of how the metrics are defined in k6 and how they’re displayed on the dashboard.
So, the fact is that while http_reqs
is defined as a Counter
(accounts the total amount of requests), http_reqs_failed
is defined as a Rate
(accounts the “rate” of failures, like a %) - see here. So, in your case, that’s why it is equals to 1
, because 100% of your requests is failing. Otherwise, it would be equals to 0.something
or equals to 0
if no request failed at all.
That said, I fully agree this is completely confusing. I would even say that it is incorrect, because in the dashboard is displayed as: 1/s
, not as 100%
, for instance. I’m even wondering if other Rate
metrics might be wrongly displayed (like showing the percentage over seconds, similarly to that 1/s
).
The next step I’d encourage you is to open an issue in the extension’s repository (aforementioned), if no one related yet, or comment on, if anyone related already exists. Feel free to point to this thread, and concretely to my comment where I explain why.
Anyway, I’ll ping the extension’s author to let them know in advance.
Thanks so much for reporting it! ![:bowing_man: :bowing_man:](https://emoji.discourse-cdn.com/twitter/bowing_man.png?v=12)
Oh wow! Thanks @joanlopez for a detailed explanation! This got me puzzled well as well!
Definitely agree that having it as 100%
on y-axis would make this much more clearer and easier to understand!
What probably adds even more to the confusion is that graph next to it goes to 1k/s - because as you said it’s counter vs rate… but not clear from dashboard itself.
Probably even more in cotext that web dashboards originally shows much higher numbers on y-axis
Also on the html report, top figure, they are overlayed so one would assume same unit.
1 Like