Counters not starting from zero?

Hi! i’ve been been working a while with k6 using output-prometheus-exporter and found something that i think it might be an error… but honestly i dont know if it is expected to work that way. so… before filling up an issue in gh i prefer to ask here.

I ran some test on a website and, while trying to understand http_req_failed metric, started to take a deeper view on http_reqs metric.

Among its labels i focused on “name”(the requests url) and “status”. I found that when responses are 200’s it properly starts from zero and count OK requests. Great! Then when there’s a 500, instead of creating a counter with status=500 from zero (as i expected) it starts with the value from 200’s metrics at that time.

For clarity, there’s a sample of a prometheus console query.

metric value
k6_http_reqs{method=“GET”, name="<endpoint_1>", proto=“HTTP/2.0”, scenario=“default”, status=“200”, tls_version=“tls1.2”} 21 @ 1642424336.711
28 @ 1642424341.125
43 @ 1642424347.734
53 @ 1642424353.064
69 @ 1642424359.359
84 @ 1642424365.442
101 @ 1642424371.087
122 @ 1642424377.045
131 @ 1642424378.63
150 @ 1642424383.799
165 @ 1642424387.92
k6_http_reqs{method=“GET”, name="<endpoint_1>", proto=“HTTP/2.0”, scenario=“default”, status=“500”, tls_version=“tls1.2”} 147 @ 1642424383.199
462 @ 1642424443.447
733 @ 1642424489.655
855 @ 1642424513.894
1444 @ 1642424608.739

You can see that status=500 counter starts from 147, and if we look at the timestamps it fits right between the 131 and 150 values of status=200, and it seems to take that value as the initial. Then… when another 500 happens same occurs, it copies the 200’s and continues from there.

Also, if i count total requests made by endpoint… those with statuses 200 and 500 doubles the ones with only one status label while it should be in avg equal with all other endpoints.

Shouldn’t those counters start from zero and count only the responses by status separately? Am i missing something?
Thanks in advance!

Hi @chudix,
Welcome to the forum :wave: and thank you for this question! This looks like a bug :joy: I created an issue here:

I hope I’ll be able to get to work on these starting from the ~ next week; but sadly, as you can see by description, solution for this is not straight-forward and is tied to major issue in k6 itself so I can give no guarantees about fast resolution at the moment. Please subscribe to the GH issues (this bug ^^ in extension and / or the issue in k6) if you’d like to receive updates of WIP. Otherwise, I’ll update here, in the topic, once the bug in extension is closed.

1 Like

Hi @olha!

Thank you very much for your response and your work.

I’ll stay tuned.