Does k6 browser support url matching patterns for thresholds?

Hey everyone,

Im currently trying to write some tests for web app within k6 experimental browser.
While I can create a threshold like this, that works just fine:

thresholds: {
‘webvital_largest_content_paint{url:www.example-url.com/somepage/someinneresource/page.html’ : [‘p(90) < 2500’],
},

Following threshold doesn’t seem to monitor trace:

thresholds: {
‘webvital_largest_content_paint{url:www.example-url.com/**’ : [‘p(90) < 2500’],
},

Is there some way to achieve this? It would be nice to be able to make some patterns for urls, like I log in to some certain page, but then id in the query string could be diffferent, so it would be more convenient to just use some general patterns like this.

Another thing is that k6 browser doesn’t seem to pick up urls for thresholds unless You use these urls in actions like await page.goto(url) or await page.reload(), are there any plans to maybe extend this thresholds measurments for redirects from page to page, without explicitly calling those page with page.goto or page.reload?

Best regards,
Artur

Hi @ArturS, welcome to the forum! :wave:

I think these are interesting points, let’s address them individually.

About the pattern matching on URL label for threshold. I think this can be an interesting feature, but this would most probably have to be supported “generically” in all metric labels.
This is more related with k6 core, so could you please write this specific part of the question in the k6 OSS forum? Or even create a Github issue for the feature request if you want. The k6 core team will address them from there.

As an alternative for your use case without requiring the pattern mathcing, we have this issue open in k6 browser which would allow labeling specific page.goto() actions, which could be used when defining the thresholds. Do you think this would fulfill your use case?

About thresholds only for the URLS used in page.goto() or page.reload(). This should not be the case. Web Vitals metrics should be measured on every loaded page. So for example, if you go to a site that returns a redirect to URL_X, there should be metrics associated for URL_X at the end of the test.
Are you experiencing different behavior? Could you provide us more details on this, or an example of a test that we can run?

Regards.