We are sending post requests to /placeorder, which will redirect to /orderdetail?p={orderid}. Because the order detail page url is unique, it results in a lot of requests recorded in k6. Sending requests with redirects = 0 helps a bit but we still want to load the order detail page. I tried with adding a tag to /placeorder/ but it seems to have no effect on the redirect. How can we group them?
Thanks.
export default function() {
http.get("https://httpbin.test.k6.io/redirect/1", {tags: {name: "httpbin"}});
which if you run with
k6 run -o json script.js
you will see the metrics generated to have the same
name
. And then just use
name
to get different requests, this is what k6 cloud does ;).
After a bit of digging and talking with colleagues, this is what we came up with
let params = {
redirects: 0
response = http.post(baseUrl + "/en/checkout/PlaceOrder/", data , params);
if (response.status !== 302) {
metaLog("Place Order :: " + response.status + "::" + response.body);
else {
response = http.get(baseUrl + response.headers["Location"], {tags: { name : "OrderConfirmation "}});
The example that I’ve given is with redirects and it does change the name
for both the redirect(s) and the initial request.
Can you provide an example that doesn’t make it?
When I simply tried with
response = http.post(baseUrl + "/en/checkout/PlaceOrder/", data , {tags: { name : "OrderConfirmation "}});
the redirect requests are still showed one by one in the list (and there are a lot of them). Not quite sure if I did something wrong
Hi @vimvq1987,
I’m not able to reproduce the behavior you’re seeing. Which k6 version are you using (output of k6 version
) and how are you running k6? Is it a local CLI test or a k6 Cloud run?
Here’s what I see on v0.28.0:
script.js
:
import http from 'k6/http';
export default function () {
http.post(
'https://httpbin.test.k6.io/redirect-to?url=https%3A%2F%2Fhttpbin.test.k6.io%2Fredirect%2F3',
{}, {tags: {name: "OrderConfirmation"}},
Running k6 run -o json=results.json script.js
produces the results.json
, which when filtered with jq
shows the name
tag is the same for all requests:
> jq '. | select(.type=="Point" and .metric == "http_reqs") | {method: .data.tags.method, url: .data.tags.url, name: .data.tags.name}' results.json
"method": "POST",
"url": "https://httpbin.test.k6.io/redirect-to?url=https%3A%2F%2Fhttpbin.test.k6.io%2Fredirect%2F3",
"name": "OrderConfirmation"
"method": "GET",
"url": "https://httpbin.test.k6.io/redirect/3",
"name": "OrderConfirmation"
"method": "GET",
"url": "https://httpbin.test.k6.io/relative-redirect/2",
"name": "OrderConfirmation"
"method": "GET",
"url": "https://httpbin.test.k6.io/relative-redirect/1",
"name": "OrderConfirmation"
"method": "GET",
"url": "https://httpbin.test.k6.io/get",
"name": "OrderConfirmation"
Can you post a runnable script example that reproduces your issue?
With my code I was able to group it like this, which works for me. If I simply add name to the POST requests, then it is recorded as individual requests
and also Too many urls warning is displayed.
I am new to this so I’m not sure if I’m doing it right. Thank you both for looking into this.
vimvq1987:
With my code I was able to group it like this, which works for me. If I simply add name to the POST requests, then it is recorded as individual requests
What do you do in your code that isn’t adding name
? As adding name
definitely works for me and @imiric it seems.