For one request, showing two HTTP status code (200, 308)

Hello All,

I ran the below-shown script and exported the results to Prometheus. When analyzing the test results in Grafana, I find both the following metrics show the same count. How can a single request produce two HTTP status codes?

k6_http_reqs{expected_response=“true”, method=“GET”, proto=“HTTP/1.1”, scenario=“default”, status=“200”, tls_version=“tls1.3”, url=“https://test.k6.io/”}

k6_http_reqs{expected_response=“true”, method=“GET”, proto=“HTTP/1.1”, scenario=“default”, status=“308”, url=“http://test.k6.io”}

import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
  vus: 100,
  duration: '120s',
};
export default function () {
  http.get('http://test.k6.io');
  sleep(1);
}

Command to run the script.

K6_PROMETHEUS_REMOTE_URL=http://localhost:9090/api/v1/write \
    /Users/test1/Documents/SF/go/bin/k6 run 02_http_get_options.js -o output-prometheus-remote

Hi @BharathM,

a 308 is a (permanent) redirect and k6 will automatically follow those if not configured otherwise.

So it first makes one request, gets 308, and then follows this redirect, making another request which gets 200.

Hope this helps you

Thank you @mstoykov for the reply, but http://test.k6.io is generating 200 only.
I have tested http://test.k6.io with Postman getting 200 only.

It definitely is returning 308 to http://test.k6.io/ (with a / at the end). You are either copying it wrong in Postman or Postman is lying to you :wink:

Hello @mstoykov , Attaching the postman screenshot.

Here is a Postman screenshot with their console out in which you can see there is a 308 response ( in which I would argue there is a slash added where it shouldn’t be)

You can also disable auto redirects in Postman from settings->general->Automatically follow redirects
image
At which point it clearly returns a 308

Thank you @mstoykov. Perfect!
(Just copying the Postman screenshot for others).