How to name redirected urls with dynamic parameters

I am scripting a fairly involved Okta authentication flow with multiple redirects. These redirects are being returned to k6 with their dynamic values, such that each time it returns, it is a different url. Very unhelpful for trending.

I understand how to tag: name my requests, but I don’t see how this can be applied to redirect urls. Has someone else run into this?

Hmm this is a bit complicated. You can use the name tag in the parent request, and it should apply to all requests. If you run this script with k6 run --out json=results.json script.js:

import http from 'k6/http';

export default function () {
    http.get('', { tags: { name: 'foo' } });

You should get 4 requests with different URLs that are all tagged with "name": "foo" when you run this on the results: jq '. | select(.type=="Point" and .metric == "http_req_duration")' results.json

If you want to tag your individual requests separately, you have to tell k6 not to follow redirects automatically by setting the maxRedirects option to 0. Then you can tag each request however you want, but you have to process each Response individually and make the next request in the redirect chain yourself (e.g. by using the Location header of the preceding Response).

Well, I am certainly tagging each request, but that part is also not working 100%.

For example, this works:

  res =`https://idp.` + environment + ``, payload, {
    tags: { name: `008 - https://idp.` + environment + `` },

but this does not:

  res =``, payload, params, {
    tags: { name: `005 -` },

If I remove the params, it does get tagged, but my request fails. So I kinda need that.

Hi @leathej1 , tags should be part of the params as explained in the Params docs.

So your third argument should be all the params. I would expect that in the second case you just have tags in the params as well that are just set where you set the rest of your params

Of course - that was silly of me. Thanks, Mihail!